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 the codes is WA,help!help!help!

Posted by kuki at 2010-08-01 18:08:11 on Problem 2080
#include<stdio.h>
int a[2][13]={0,31,28,31,30,31,30,31,31,30,31,30,31,
          0,31,29,31,30,31,30,31,31,30,31,30,31};
int c[2]={365,366};
char * week[7]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
int fun(int x)
{
	if(x%400==0||x%4==0&&x%100!=0)
		return 1;
	else
		return 0;
}
int main()
{
	int N;
	int year;
	int i;
	FILE * fp;
	fp=fopen("G:\\C++\\std.txt","r");
	while(fscanf(fp,"%d",&N)&&N!=-1)
	{
		int WEEK;
		year=2000;
		WEEK=(6+N)%7;
		int k=fun(year);
		while(N>=c[k])
		{
			N-=c[k];
			year++;
			k=fun(year);
		}
		i=1;
		while(N>=a[k][i])
		{
			N-=a[k][i];
			i++;
		}
		int month=i--;
		int day;
		day=N+1;
		printf("%d-%02d-%02d %s\n",year,month,day,week[WEEK]);
		//fscanf(fp,"%d",&N);

	}
	fclose(fp);
	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