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 wic at 2008-01-30 13:22:29 on Problem 1006
#include<stdio.h>
int main()
{
	int i,j,k;
	int a[4];
	
	for(i=0;;i++)
	{
		for(j=0;j<4;j++)
			scanf("%d",&a[j]);
				if(a[0]==-1&&a[1]==-1&&a[2]==-1&&a[3]==-1)
				break;
		if((a[0]<0||a[0]>365)||(a[1]<0||a[1]>365)||(a[2]<0||a[2]>365)||(a[3]<0||a[3]>365))
		{	i--;
			continue;
		}
		else
		{
		
			if(a[0]==0&&a[1]==0&&a[2]==0&&a[3]==0)
				k=21252;
			else
			{
					for(k=0;k<=21252;k++)
					if((k+a[3]-a[0])%23==0&&(k+a[3]-a[1])%28==0&&(k+a[3]-a[2])%33==0)
					break;
									
			}	
			printf("Case %d: the next triple peak occurs in %d days.\n",i+1,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