| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
能帮我看看是哪里错了吗? 已经好几天了,还没有找到错误#include"stdio.h"
#include"stdlib.h"
int cmp ( const void *a , const void *b )
{
return *(int *)a - *(int *)b;
}
main(){
int a,b,c[100][100],i,j,k[10000],x,y,m[100][100],n[4];
while(scanf("%d %d",&a,&b)==2){
for(i=0;i<a;i++)
for(j=0;j<b;j++){
c[i][j]=0;
m[i][j]=0;
}
for(i=0;i<a;i++)
for(j=0;j<b;j++){
scanf("%d",&c[i][j]);
k[a*i+j]=c[i][j];
}
qsort(k,a*b,sizeof(k[0]),cmp);
for(x=0;x<a*b;x++)
for(i=0;i<a;i++)
for(j=0;j<b;j++)
if(c[i][j]==k[x]){
if(c[i][j]==k[0]) m[i][j]=1;
else{
if(j>=1&&c[i][j]>c[i][j-1]) n[0]=m[i][j-1];
else n[0]=0;
if(j+1<b&&c[i][j]>c[i][j+1]) n[1]=m[i][j+1];
else n[1]=0;
if(i>=1&&c[i][j]>c[i-1][j]) n[2]=m[i-1][j];
else n[2]=0;
if(i+1<a&&c[i][j]>c[i+1][j]) n[3]=m[i+1][j];
else n[3]=0;
qsort(n,4,sizeof(n[0]),cmp);
m[i][j]=n[3]+1;
}
}
y=0;
for(i=0;i<a;i++)
for(j=0;j<b;j++)
if(m[i][j]>y) y=m[i][j];
printf("%d\n",y);
}
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator