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

各位大牛看一看?WHY WRONG

Posted by zhouxiaozi at 2009-04-06 15:16:22 on Problem 3047
#include <stdio.h>
int getday(int year,int month,int day) 
{ 
	int flag,s,i; 
	int a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; 
	int cont=0;
	if((year%4==0&&year%100!=0)||year%400==0)
		flag=1;
	else 
		flag=0;
	//flag=isleap(year); 
	if(flag==1) 
		a[2]++; 
	for(i=1;i<month;i++) 
	{ 
		cont=cont+a[i]; 
	} 
    cont=cont+day; 
    s=year+1+(year-1)/4+(year-1)/100+(year-1)/400+cont; 
    return s%7;
}
int main()
{
	int n,m,k;
	scanf("%d%d%d",&n,&m,&k);
	int ans=getday(n,m,k);
	if(ans==0)
		printf("sunday\n");
	else if(ans==1)
		printf("monday\n");
	else if(ans==2)
		printf("tuesday\n");
	else if(ans==3)
		printf("wednesday\n");
	else if(ans==4)
		printf("thursday\n");
	else if(ans==5)
		printf("friday\n");
	else 
		printf("saturday\n");
	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