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 is it WA??大牛请进!!

Posted by sailors at 2007-04-18 19:43:45 on Problem 2080
#include<iostream.h>
#include<math.h>
struct CA
{
	int year;
	int mon;
	int day;
	int dayofweek;
};
CA ca;
int work_dayofweek(int n)
{
	int x=n%7;
	switch(x)
	{
	case 0:
		cout<<"Saturday"<<endl;;break;
	case 1:
		cout<<"Sunday"<<endl;break;
	case 2:
		cout<<"Monday"<<endl;break;
	case 3:
		cout<<"Tuesday"<<endl;break;
	case 4:
		cout<<"Wednesday"<<endl;break;
	case 5:
		cout<<"Thursday"<<endl;break;
	case 6:
		cout<<"Friday"<<endl;break; 
	}
	return 0;
}
int work(int day)
{

		if(day<=31)ca.mon=1;
		else
		{
			day-=31;
			if(day<=29)ca.mon=2;
			else
			{
				if(ca.year%4==0&&ca.year%100!=0||ca.year%400==0)
				{
					day-=29;
				}
				else
				{
					day-=28;
				}
					if(day<=31)ca.mon=3;
					else
					{
						day-=31;
						if(day<=30)ca.mon=4;
						else
						{
							day-=30;
							if(day<=31)ca.mon=5;
							else
							{
								day-=31;
								if(day<=30)ca.mon=6;
								else
								{
									day-=30;
									if(day<=31)ca.mon=7;
									else
									{
										day-=31;
										if(day<=31)ca.mon=8;
										else
										{
											day-=31;
											if(day<=30)ca.mon=9;
											else
											{
												day-=30;
												if(day<=31)ca.mon=10;
												else
												{
													day-=31;
													if(day<=30)ca.mon=11;
													else
													{
														day-=30;
														if(day<=31)ca.mon=12;
													}
												}
											}
										}
									}
								}
							}
						}
					}
			}
		}
		ca.day=day+1;
		return 0;


}

int output(int n)
{
	cout<<ca.year<<'-';
	if(ca.mon<10)cout<<'0';
	cout<<ca.mon<<'-';
	if(ca.day<10)cout<<'0';
	cout<<ca.day<<' ';
	work_dayofweek(n);
	return 0;
}
int main()
{
	int n;
	int day;
	int i;
	while(cin>>day&&day!=-1)
	{
		n=day;
		i=2000;
		
			while(day>365)
			{
				if(i%4==0&&i%100!=0||i%400==0)
				{
					day-=366;
				
				}
				else
				{
					day-=365;
				}
				i++;
			}

		
		ca.year=i;
		work(day);
		output(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