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 wsniyufang at 2010-12-06 22:42:55 on Problem 1088
#include<iostream>
#include<stdio.h>
using namespace std;
int r,c;
int a[102][102];
int l[102][102];
int f(int i,int j);
int main()
{int i,j;
	cin>>r>>c;
for(i=0;i<r;i++)
for(j=0;j<c;j++)
{cin>>a[i][j];l[i][j]=0;}
int maxlen=0;
		for(i=0;i<r;i++)
		{
			for(j=0;j<c;j++)
			{
				l[i][j]=f(i,j);
			if(l[i][j]>maxlen)
			maxlen=l[i][j];
			}
		}
printf("%d\n",maxlen);
return 0;
}




int f(int i,int j)
{int x,max=0;
if(l[i][j]>0)
return l[i][j];

if(i-1>=0&&a[i-1][j]<a[i][j])
{x=1+f(i-1,j);
if(x>max)
max=x;}
if(j-1>=0&&a[i][j-1]<a[i][j])
{x=1+f(i,j-1);
if(x>max)
max=x;}
if(i+1<r&&a[i+1][j]<a[i][j]);
{x=1+f(i+1,j);
if(x>max)
max=x;}
if(j+1<c&&a[i][j+1]<a[i][j])
{x=1+f(i,j+1);
if(x>max)
max=x;}
return max;
}

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