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

QUESTION: Is the year FOUR a leap year?

Posted by frkstyc at 2005-08-07 23:59:40 on Problem 2080
In Reply To:对着数据测了一遍,,发现没错,还有什么要考虑的吗??再次麻烦老大。。。。 Posted by:SilenceIowyh at 2005-08-07 23:32:05
> #include<stdio.h>
> void main()
> {
> 	int t1[12]={31,28,31,30,31,30,31,31,30,31,30,31},
> 		t2[12]={31,29,31,30,31,30,31,31,30,31,30,31};
> 	char qx[7][15]={"Friday","Saturday","Sunday", "Monday", "Tuesday", "Wednesday","Thursday"};
> 	int n,k,y,m,d,i,xq;
> 
> 	while(1)
> 	{
> 		scanf("%d",&n);
> 		if(n==-1)  break;
> 			n+=1;
> 		y=2000;m=1;d=1;
> 		k=n;
> 		while(1)
> 		{
> 			if((y%4==0&&y%100!=0&&k>366)||(y%400==0&&k>366))
> 			{
> 				k=k-366;y++;
> 			}
>              else if(k>365)
> 			 {
> 				 	k=k-365;y++;
> 			 }
> 			 else break;
> 		}
> 		if((y%4==0&&y%100!=0)||(y%400==0))
> 		{
> 			for(i=0;;i++)
> 				if(k>t2[i])  {k=k-t2[i];m++;}
> 				else break;
> 		}
> 		else
> 		{	
> 			for(i=0;;i++)
> 				if(k>t1[i])  {k=k-t1[i];m++;}
> 				else break;
> 		}
> 		xq=n%7;
> 		d=k;
> 		if(m<10&&d<10)
> 		printf("%d-0%d-0%d %s\n",y,m,d,qx[xq]);
> 		else if(m>=10&&d<10)
> 		printf("%d-%d-0%d %s\n",y,m,d,qx[xq]);
> 		else if(m<10&&d>=10)
> 		printf("%d-0%d-%d %s\n",y,m,d,qx[xq]);
> 		else
> 		printf("%d-%d-%d %s\n",y,m,d,qx[xq]);
> 	}
> }
> 
> 
> 
> 
> 
> 
> 
> 

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