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 Blus at 2006-12-11 20:41:46 on Problem 1044
In Reply To:伟大的系统又在为难我了……谁有刁钻的数据啊…… Posted by:Blus at 2006-12-11 17:50:27
#include<iostream>
using namespace std;

const long uplimite=10000;
int k=1;

int main()
{
	long y[20];
	long a[20];
	long b[20];
	long bd[20];//a与b的差
	int i;
	int n;
	bool flag=false;

	while(1)
	{
		cin>>n;
		if(n==0) break;

		for(i=0;i<n;i++)
		{
			cin>>y[i]>>a[i]>>b[i];
			bd[i]=b[i]-a[i];
		}

/*=================================================================
	1.先将y[0]=y[1],然后再看y[0]是否=y[2],如果是,则依次重复.
	2.如果出现当y[2]>y[0]时也不能使y[2]=y[0],
	3.那么y[0]+bd[0],并重新从第1行开始.
	4.如果找到那个数为true,并跳出.
	5.如果为找到为false,并跳出.
*/==================================================================
		if(n!=1)
		while(1)
		{
			if(y[0]>uplimite)
					break;

			for(i=1;i<n;)
			{
				while(1)
				{
					if(y[i]==y[0])
					{
						flag=true;
						break;
					}
					if(y[i]>y[0] || y[i]>uplimite)
					{
						flag=false;
						break;
					}
					y[i]+=bd[i];
				}
				
				if(flag)
				{
					i++;
					continue;
				}

				if(y[i]>uplimite)
				{
					flag=false;
					break;
				}

				if(!flag)
				{
					y[0]+=bd[0];
					flag=false;
					i=0;
				}	
				
				if(y[0]>uplimite)
					break;
			}
			
			if(y[i]>uplimite)
			{
				flag=false;
				break;
			}

			if(flag)
				break;
		}
//==============================================================
		else
			flag=true;

		cout<<"Case #"<<k<<":"<<endl;
		
		if(flag)
		{
			cout<<"The actual year is "<<y[0]<<"."<<endl<<endl;
		}
		else
			cout<<"Unknown bugs detected."<<endl<<endl;
		k++;
	}
	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