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 Purpledatura at 2017-05-14 00:32:30 on Problem 2080 and last updated at 2017-05-14 00:36:54
#include<stdio.h>
#include<math.h>
#include<string.h>
#define p 1
#define r 0

int years,months,days;

int year_p_r(int n)	
{
	if(n%400==0||(n%100!=0&&n%4==0))
		return r;
return p;
}

void date(int n)
{
	int i;
	int ping[12]={31,28,31,30,31,30,31,31,30,31,30,31};
	int run[12]={31,29,31,30,31,30,31,31,30,31,30,31};
	years=2000;
	while(n>=366)
	{
		if(year_p_r(years)==r)
			n-=366;
		else n-=365;
		years++;
	}
	if(year_p_r(years)==p&&n>=365)
	{
		n-=365;
		years++;
	}
	if(year_p_r(years)==p)
	{
		int i;
		for(i=0;i<12;i++)
		{
			n-=ping[i];
			if(n<=0)
				break;
		}
		months=i+1;
		days=n+ping[i]+1;
	}
	else
	{
		for(i=0;i<12;i++)
		{
			n-=run[i];
			if(n<=0)
				break;
		}
		months=i+1;
		days=n+run[i]+1;
	}
}

int week_n(int n)
{
	n+=6;
	n%=7;
return n;
}

int main()
{
	int n;
	char week[7][12]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
	scanf("%d",&n);
	while(n+1)
	{
		date(n);
		printf("%04d-%02d-%02d ",years,months,days);
		puts(week[week_n(n)]);
		scanf("%d",&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