Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

各位大牛帮忙看看问题出哪里了。谢了

Posted by Maycode at 2009-03-20 09:48:43
#include<iostream>
using namespace std;
int move[2][4]={0,-1,0,1,1,0,-1,0};
int R,C;
int h[101][101];
int flag[101][101];
int find(int r,int c)
{
     int i,newr,newc,temp,max=1;
     for(i=0;i<4;i++)
     {
         newr=r+move[0][i];
         newc=c+move[1][i];
         
         if(flag[newr][newc]==-1&&h[newr][newc]<h[r][c])
         {
              
              temp=find(newr,newc);
              if(max<temp+1)
                  max=temp+1;

             
         }
     }
     return max;
     
}
int main()
{
    int i,j,temp,max=0;
    cin>>R>>C;
    for(i=1;i<=R;i++)
    {
        for(j=1;j<=C;j++)
        {
            cin>>h[i][j];
            flag[i][j]=-1;                 
        }
    }
    for(i=1;i<=R;i++)
    {
        for(j=1;j<=C;j++)
        {
            
            temp=find(i,j);
            if(temp>max)
                max=temp;
           
                             
        }
    }
    cout<<max<<endl;   
   system("pause");
    return 0;    
}
我发现这个程序有时候死循环了。。。

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator