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 <iostream.h> #include <memory.h> int max(int a,int b,int c,int d) { int y,z=0; if (a>b) y=a; else y=b; if (c>d) z=c; else z=d; if (y>z) { return y; } else { return z; } } char matrix[20][20]; int hang,lie=0; int compare(int a,int b,int letter[26]) { letter[int (matrix[a][b])-65]=1; int test[4]; memset (test,0,sizeof (test)); if ((a-1==-1)||(letter[int(matrix[a-1][b])-65]==1)) { test[0]=0; } else { test[0]=1+compare(a-1,b,letter); } if ((a+1==hang)||(letter[int (matrix[a+1][b])-65]==1)) { test[1]=0; } else { test[1]=1+compare(a+1,b,letter); } if ((b-1==-1)||(letter[int (matrix[a][b-1])-65]==1)) { test[2]=0; } else { test[2]=1+compare(a,b-1,letter); } if ((b+1==lie)||(letter[int (matrix[a][b+1])-65]==1)) { test[3]==0; } else { test[3]=1+compare(a,b+1,letter); } return max(test[1],test[0],test[2],test[3]); } int main() { int a,b=0; cin>>hang>>lie; for (a=0;a<hang;a++) for (b=0;b<lie;b++) cin>>matrix[a][b]; int letter[26]; memset (letter,0,sizeof (letter)); int u=0; u=compare(0,0,letter); cout<<u+1<<endl; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator