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

补一下2080的代码,大虾,求教了

Posted by lpc0220 at 2007-05-18 17:22:32
#include <iostream>
using namespace std;

//int year[7]={1461,2922,4383,6844,8305,9766,9999}
//int month[4]={366,731,1096,1461};
//int day1[12]={31,60,91,121,152,182,213,244,274,305,335,366}
//int day2[12]={31,59,90,120,151,181,212,243,273,304,334,365}

int main(){
	long  N;
	cin>>N;
	int flag_year=0;
	int flag_month=0;
	while (N!=-1)
	{
		long  M=N;
		while (N-1461>0)
		{
			N=N-1461;
			flag_year+=1;
		}
		if (N<=366)
		{
			flag_month=1;
			cout<<2000+flag_year*4;
		}
		else if (N>366&&N<=731)
		{
			flag_month=2;
			N=N-366;
			cout<<2000+flag_year*4+1;
		}
		else if (N>731&&N<=1096)
		{
			flag_month=3;
			N=N-731;
			cout<<2000+flag_year*4+2;
		}
		else if (N>1096&&N<=1461)
		{
			flag_month=4;
			N=N-1096;
			cout<<2000+flag_year*4+3;
		}
		cout<<'-';
		if (flag_month=1)
		{
			if (N<31)
			{
				cout<<"01";
			}
			else if (N>=31&&N<60)
			{
				cout<<"02";
				N=N-31;
			}
			else if (N>=60&&N<91)
			{
			    cout<<"03";
				N=N-60;
			}
			else if (N>=91&&N<121)
			{
				cout<<"04";
				N=N-91;
			}
			else if (N>=121&&N<152)
			{
				cout<<"05";
				N=N-121;
			}
			else if (N>=152&&N<182)
			{
				cout<<"06";
				N=N-152;
			}
			else if (N>=182&&N<213)
			{
				cout<<"07";
				N=N-182;
			}
			else if (N>=213&&N<244)
			{
				cout<<"08";
				N=N-213;
			}
			else if (N>=244&&N<274)
			{
				cout<<"09";
				N=N-244;
			}
			else if (N>=274&&N<305)
			{
				cout<<"10";
				N=N-274;
			}
			else if (N>=305&&N<335)
			{
				cout<<"11";
				N=N-305;
			}
			else if (N>=335&&N<366)
			{
				cout<<"12";
				N=N-335;
			}
		}
		else 
		{
			if (N<31)
			{
				cout<<"01";
			}
			else if (N>=31&&N<59)
			{
				cout<<"02";
				N=N-31;
			}
			else if (N>=59&&N<90)
			{
				cout<<"03";
				N=N-59;
			}
			else if (N>=90&&N<120)
			{
				cout<<"04";
				N=N-90;
			}
			else if (N>=120&&N<151)
			{
				cout<<"05";
				N=N-120;
			}
			else if (N>=151&&N<181)
			{
				cout<<"06";
				N=N-151;
			}
			else if (N>=181&&N<212)
			{
				cout<<"07";
				N=N-181;
			}
			else if (N>=212&&N<243)
			{
				cout<<"08";
				N=N-212;
			}
			else if (N>=243&&N<273)
			{
				cout<<"09";
				N=N-243;
			}
			else if (N>=273&&N<304)
			{
				cout<<"10";
				N=N-273;
			}
			else if (N>=304&&N<334)
			{
				cout<<"11";
				N=N-304;
			}
			else if (N>=334&&N<365)
			{
				cout<<"12";
				N=N-334;
			}
		}
		cout<<'-';
		if (N<=8)
			cout<<'0';
		cout<<N+1<<' ';
		int remainder_day=M%7;
		if (remainder_day==1)
			cout<<"Sunday"<<endl;
		else if(remainder_day==2)
			cout<<"Monday"<<endl;
		else if(remainder_day==3)
			cout<<"Tuesday"<<endl;
		else if(remainder_day==4)
			cout<<"Wednesday"<<endl;
		else if(remainder_day==5)
			cout<<"Thursday"<<endl;
		else if(remainder_day==6)
			cout<<"Friday"<<endl;
		else if(remainder_day==0)
			cout<<"Saturday"<<endl;
		cin>>N;
		flag_year=0;
		flag_month=0;
	}
	return 1;
}

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