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

Run Time Error??????Why???Who can tell me??? Prob 1006

Posted by Ceoalpha at 2006-03-24 19:59:49
#include<iostream>
using namespace std;

int max(int i, int j)
	{
		if(i>=j)
			return i;
		else return j;
	}

void main()
{
	int p[100],e[100],i[100],d[100];
	int ans;
	long int day;
	int cnt=0;
	bool flag=true;
	while(flag)
	{
		cin>>p[cnt]>>e[cnt]>>i[cnt]>>d[cnt];
		if(p[cnt]==-1 && e[cnt]==-1 && i[cnt]==-1 && d[cnt]==-1)
			flag=false;
		cnt++;
	}

	for(int j=0;j<cnt-1;j++)
	{
		day=p[j];
		flag=true;
		for(int k = max(max(max(p[j],e[j]), i[j])+1, 23); ;k++) 
		{
			if(((k - p[j])%23 == (k - e[j])%28) && ((k-p[j])%23 == (k-i[j]) % 33)) {
				day=k;
				break;
			}
		}

		ans=day-d[j];
		cout<<"Case "<<j+1<<": the next triple peak occurs in "<<ans<<" days."<<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