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:0MS的递归In Reply To:0MS的递归 Posted by:poiulkj at 2007-05-18 09:24:29 > #include<iostream.h> > int r,c,a[101][101],flag[101][101]; > int huaxue(int i,int j) > { > int temp,max=1; > if(flag[i][j]!=-1) return flag[i][j]; > if(a[i][j]>a[i-1][j]&&i>1) > { temp=huaxue(i-1,j); > if(max<temp+1) max=temp+1; > } > if(a[i][j]>a[i][j-1]&&j>1) > { temp=huaxue(i,j-1); > if(max<temp+1) max=temp+1; > } > if(a[i][j]>a[i+1][j]&&i<r) > { temp=huaxue(i+1,j); > if(max<temp+1) max=temp+1; > } > if(a[i][j]>a[i][j+1]&&j<c) > { temp=huaxue(i,j+1); > if(max<temp+1) max=temp+1; > } > flag[i][j]=max; > return max; > } > > void main() > { > int i,j,temp,max=0; > cin>>r>>c; > for(i=1;i<=r;i++) > for(j=1;j<=c;j++) > {cin>>a[i][j]; > flag[i][j]=-1; > } > for(i=1;i<=r;i++) > for(j=1;j<=c;j++) > {temp=huaxue(i,j); > if(max<temp) max=temp; > } > cout<<max<<endl; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator