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

Re:你怎么知道你已经对了?

Posted by ferrettemp at 2004-12-30 11:31:02 on Problem 2080
In Reply To:你怎么知道你已经对了? Posted by:hawk at 2004-12-30 10:23:03
我认为是对的.
对系统的测试input也验证过了.
#include "iostream"
using namespace std;
int main()
{
	int moban[2][13]={{365,31,28,31,30,31,30,31,31,30,31,30,31},
	{366,31,29,31,30,31,30,31,31,30,31,30,31}};
	int nian,yue,ri,i,runnian,xingqi,temp;
	int xinxi[10000];
	i=0;
	while(1>0)
	{
		do {cin>>xinxi[i];
		}while(xinxi[i]<=0&&xinxi[i]!=-1||xinxi[i]>2921939);
		if (xinxi[i]==-1)
			break;
		i++;
	}
	i=0;
	while(1>0)
	{
		if (xinxi[i]==-1)
			break;
		temp=xinxi[i];
		nian=2000,yue=1,ri=1;
		runnian=nian%4==0&&nian%100!=0||nian%400==0;
		while(xinxi[i]>=moban[runnian][0])
		{
			xinxi[i]-=moban[runnian][0];
			nian++;
			runnian=nian%4==0&&nian%100!=0||nian%400==0;
		}
		while(xinxi[i]>=moban[runnian][yue])
		{
			xinxi[i]-=moban[runnian][yue];
			yue++;
		}
		if (xinxi[i]>0)
			ri+=xinxi[i];
		xingqi=(6+temp)%7;
		cout<<nian<<"-";
		if (yue<10)
			cout<<'0'<<yue<<"-";
		else cout<<yue<<"-";
		if (ri<10)
			cout<<'0'<<ri<<" ";
		else cout<<ri<<" ";
		switch(xingqi)
		{
		         case 0:cout<<"Sunday"<<endl;break;
			case 1:cout<<"Monday"<<endl;break;
		         case 2:cout<<"Tuesday"<<endl;break;
			case 3:cout<<"Wednesday"<<endl;break;
			case 4:cout<<"Thursday"<<endl;break;
			case 5:cout<<"Friday"<<endl;break;
			case 6:cout<<"Saturday"<<endl;break;
		}
		i++;
	}
	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