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 <iostream> using namespace std; int pmap[101][101],n,m,p,times,resn,resm; void getnum(int n,int m,int t) //n行,m列 { switch(t) { case 1: { resn=n-1;resm=m; break; } case 2: { resn=n;resm=m-1; break; } case 3: { resn=n+1;resm=m; break; } case 4:{ resn=n;resm=m+1; } } } int gettimes(int hang,int lie) { //cout<<"pos:"<<hang<<" "<<lie<<endl; times++; int nownum=pmap[hang][lie],pmin=pmap[hang][lie],pmax=0,ph=102,pl=102,bh=102,bl=102,n; for(int i=1;i<5;i++) { getnum(hang,lie,i); int nn[]={resn,resm}; if(nn[0]<0 || nn[1]<0) continue; //cout<<"t:"<<times<<" "<<nn[0]<<" "<<nn[1]<<" "<<i<<endl; if(pmap[nn[0]][nn[1]]>pmax && pmap[nn[0]][nn[1]]<nownum) { pmax=pmap[nn[0]][nn[1]]; bh=nn[0]; bl=nn[1]; } if(pmap[nn[0]][nn[1]]<pmin) { pmin=pmap[nn[0]][nn[1]]; ph=nn[0]; pl=nn[1]; } } if(pmin==10001 ||(ph==102 && pl==102) ||(bh==102 && bl==102) || pmax==0) return times; //cout<<"re"<<endl; gettimes(bh,bl); } int main() { int tto; cin>>m>>n; for(int i=0;i<m;i++) //行 { for(int j=0;j<n;j++) { //列 cin>>p; pmap[i][j]=p; //前为行,后为列 } } //cout<<pmap[4][4]; //cin>>tto; //getnum(0,0,tto); //cout<<resn<<" "<<resm<<" "<<pmap[resn][resm]<<endl; int nmax=0,now; for(int ii=0;ii<m;ii++) { //cout<<ii<<endl; for(int jj=0;jj<n;jj++) { times=0; //cout<<ii<<" "<<jj<<endl; //cout<<"restarted"<<endl; now=gettimes(ii,jj); if(now>nmax) nmax=now; } } cout<<nmax<<endl; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator