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 |
我是也觉得应该是那样的,可是我的程序运行时绝对没有任何问题,不知道哪位牛人看看?In Reply To:Re:Runtime Error 是运行时发生错误 Posted by:mixter at 2006-12-06 18:51:35 #include <iostream.h> int data[100][100]; int x=0; int y=0; int length=1; int temp=0; void Find(int * maxX,int * maxY) { int t=0; int i=0; for(i=0;i<x;i++) for(int j=0;j<y;j++) { if(data[i][j]>t) { *maxY=j; *maxX=i; t=data[i][j]; } } } int run(int m,int n) { int len=0; int ted=0; int t=0; while(true) { switch(t) { case 0: if(m==0) break; if(data[m-1][n]>=data[m][n]) break; if(data[m-1][n]<=0) { ted=-data[m-1][n]; } else ted=run(m-1,n); break; case 1: if(n==(y-1)) break; if(data[m][n+1]>=data[m][n]) break; if(data[m][n+1]<=0) { ted=-data[m][n+1]; } else ted=run(m,n+1); break; case 2: if(m==(x-1)) break; if(data[m+1][n]>=data[m][n]) break; if(data[m+1][n]<=0) { ted=-data[m+1][n]; } else ted=run(m+1,n); break; case 3: if(n==0) break; if(data[m][n-1]>=data[m][n]) break; if(data[m][n-1]<=0) ted=-data[m][n-1]; else ted=run(m,n-1); break; default: data[m][n]=- ++len; break; } if(t==4) break; t++; if(len<ted) len=ted; ted=0; } return len; } void main() { cin>>x>>y; for(int i=0;i<x;i++) for(int j=0;j<y;j++) cin>>data[i][j]; for(i=0;i<x*y;i++) { int m,n; Find(&m,&n); if(data[m][n]>0) temp=run(m,n); else continue; if(temp>length) length=temp; } cout<<length<<endl; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator