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 |
Re:救命啊!!!!!!!!!!In Reply To:救命啊!!!!!!!!!! Posted by:LiWang112358 at 2008-11-12 19:34:37 > 那位大侠帮看看。 > 所有数据都过,就是RUNTIME ERROR > #include <stdio.h> > int a[101][101]={0},f[101][101]; > int main() > { > > int search(int x,int y); > int i,j,r,c,max; > extern int a[101][101],f[101][101]; > scanf("%d %d",&r,&c); > for (i=0;i<=101;i++) > for (j=0;j<=101;j++) > { > f[i][j]=-1; > a[i][j]=-1; > } > for(i=1;i<=r;i++) > for(j=1;j<=c;j++) > scanf("%d",&a[i][j]); > > max=-1; > for(i=1;i<=r;i++) > for(j=1;j<=c;j++) > { > f[i][j]=search(i,j); > if (max<f[i][j]) max=f[i][j]; > } > printf("%d\n",max); > } > int ma(int x,int y) > { > if (x>y) return x; > else return y; > } > int search(int x,int y) > { > extern int a[101][101]; > int a1,b,c,d,ans,m; > if (a[x][y]==-1) return 0; > if ((f[x-1][y]==-1)&&(a[x][y]>=a[x-1][y])) > { > a1=search(x-1,y); > f[x-1][y]=a1; > } > if ((f[x][y-1]==-1)&&(a[x][y]>=a[x][y-1])) > { > b=search(x,y-1); > f[x][y-1]=b; > } > if ((f[x][y+1]==-1)&&(a[x][y]>=a[x][y+1])) > { > c=search(x,y+1); > f[x][y+1]=c; > } > if ((f[x+1][y]==-1)&&(a[x][y]>=a[x+1][y])) > { > d=search(x+1,y); > f[x+1][y]=d; > } > m=-1; > ans=0; > if (a[x][y]>=a[x-1][y]) m=ma(m,f[x-1][y]); > if (a[x][y]>=a[x][y-1]) m=ma(m,f[x][y-1]); > if (a[x][y]>=a[x+1][y]) m=ma(m,f[x+1][y]); > if (a[x][y]>=a[x][y+1]) m=ma(m,f[x][y+1]); > ans=ans+m+1; > return ans; > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator