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 forceil at 2006-12-06 18:54:29 on Problem 1088
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:
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