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 |
求教大牛...这段代码为何WA...不胜感激....#include<stdio.h> int num[100][100]; int length[100][100]; int r,c; int getLength(int i,int j) { if(length[i][j]>0) { return length[i][j]; } int max=0; if((i!=0)&&(num[i][j]>num[i-1][j])) { int x=getLength(i-1,j)+1; if(max<x) { max=x; } } if((i!=r-1)&&(num[i][j]>num[i+1][j])) { int x=getLength(i+1,j)+1; if(max<x) { max=x; } } if((j!=0)&&(num[i][j]>num[i][j-1])) { int x=getLength(i,j-1)+1; if(max<x) { max=x; } } if((j!=r-1)&&(num[i][j]>num[i][j+1])) { int x=getLength(i,j+1)+1; if(max<x) { max=x; } } return max; } int main() { scanf("%d",&r); scanf("%d",&c); int i,j; for(i=0;i<r;i++) { for(j=0;j<c;j++) { scanf("%d",&num[i][j]); length[i][j]=0; } } int maxLen=0; for(i=0;i<r;i++) { for(j=0;j<c;j++) { length[i][j]=getLength(i,j); if(maxLen<length[i][j]) { maxLen=length[i][j]; } } } printf("%d\n",maxLen+1); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator