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

看过很多测试数据 就是WA 帮忙 谢谢~~

Posted by gucun4848 at 2008-07-16 12:40:00 on Problem 2080
/* Note:Your choice is C IDE */
#include "stdio.h"
int main()
{
	int n,year,month,temp,day;
	int leap(int a);
	scanf("%d",&day);
	while(day!=-1)
		{
		temp=day;
		n=day;
		year=2000;
		while(n/365>0)
			{
			if(leap(year))
				{
				n=n-366;
				year++;
				}
			else
				{
				n=n-365;
				year++;	
				}
			}
		if(leap(year))
			{
		 	if(n<31&&n>=0)
		 		{
		 		month=1;	
		 		}
		 	else if(n>=31&&n<60)
		 		{
		 		month=2;
		 		n=n-31;	
		 		}
		 	else if(n>=60&&n<91)
		 		{
		 		month=3;
		 		n=n-60;	
		 		}
		 	else if(n>=91&&n<121)
		 		{
		 		month=4;
		 		n=n-91;	
		 		}
		 	else if(n>=121&&n<152)
		 		{
		 		month=5;
		 		n=n-121;	
		 		}
		 	else if(n>=152&&n<182)
		 		{
		 		month=6;
		 		n=n-152;	
		 		}
		 	else if(n>=182&&n<213)
		 		{
		 		month=7;
		 		n=n-182;	
		 		}
		 	else if(n>=213&&n<244)
		 		{
		 		month=8;
		 		n=n-213;	
		 		}
		 	else if(n>=244&&n<274)
		 		{
		 		month=9;
		 		n=n-244;	
		 		}
		 	else if(n>=274&&n<305)
		 		{
		 		month=10;
		 		n=n-274;	
		 		}
		 	else if(n>=305&&n<335)
		 		{
		 		month=11;
		 		n=n-305;	
		 		}
		 	else if(n>=335&&n<366)
		 		{
		 		month=12;
		 		n=n-335;	
		 		}
		 	printf("%d-",year);
		 	if(month<10)
		 		printf("0");
		 	printf("%d-",month);
		 	if(n<9)
		 		printf("0");
		 	printf("%d ",n+1);
		 	switch(temp%7)
		 		{
		 		case 6:
		 			{printf("Friday\n");break;}
		 		case 0:
		 			{printf("Saturday\n");break;}
		 		case 1:
		 			{printf("Sunday\n");break;}
		 		case 2:
		 			{printf("Monday\n");break;}
		 		case 3:
		 			{printf("Tuesday\n");break;}
		 		case 4:
		 			{printf("Wednesday\n");break;}
		 		case 5:
		 			{printf("Thursday\n");break;}
		 		}
			}
		 else
		 	{
		 	if(n<31&&n>=0)
		 		{
		 		month=1;	
		 		}
		 	else if(n>=31&&n<59)
		 		{
		 		month=2;
		 		n=n-31;	
		 		}
		 	else if(n>=59&&n<90)
		 		{
		 		month=3;
		 		n=n-59;	
		 		}
		 	else if(n>=90&&n<120)
		 		{
		 		month=4;
		 		n=n-90;	
		 		}
		 	else if(n>=120&&n<151)
		 		{
		 		month=5;
		 		n=n-120;	
		 		}
		 	else if(n>=151&&n<181)
		 		{
		 		month=6;
		 		n=n-151;	
		 		}
		 	else if(n>=181&&n<212)
		 		{
		 		month=7;
		 		n=n-181;	
		 		}
		 	else if(n>=212&&n<243)
		 		{
		 		month=8;
		 		n=n-212;	
		 		}
		 	else if(n>=243&&n<273)
		 		{
		 		month=9;
		 		n=n-243;	
		 		}
		 	else if(n>=273&&n<304)
		 		{
		 		month=10;
		 		n=n-273;	
		 		}
		 	else if(n>=304&&n<334)
		 		{
		 		month=11;
		 		n=n-304;	
		 		}
		 	else if(n>=334&&n<365)
		 		{
		 		month=12;
		 		n=n-334;	
		 		}
		 	printf("%d-",year);
		 	if(month<10)
		 		printf("0");
		 	printf("%d-",month);
		 	if(n<9)
		 		printf("0");
		 	printf("%d ",n+1);
		 	switch(temp%7)
		 		{
		 		case 6:
		 			{printf("Friday\n");break;}
		 		case 0:
		 			{printf("Saturday\n");break;}
		 		case 1:
		 			{printf("Sunday\n");break;}
		 		case 2:
		 			{printf("Monday\n");break;}
		 		case 3:
		 			{printf("Tuesday\n");break;}
		 		case 4:
		 			{printf("Wednesday\n");break;}
		 		case 5:
		 			{printf("Thursday\n");break;}
		 		}
		 	}
		 scanf("%d",&day);
		}
	return 0;	
}
int leap(int a)
{
	int flag=0;
	if(a%400==0||(a%4==0&&a%100!=0))	
		flag=1;
	return flag;
}

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