#include<iostream> int nian(int year); int yue(int year,int month); using namespace std; //------------------------------- void main() { int year,month,day,sum,pp; char x; cout<<"Please input a day:year/month/day!"; cin>>year>>x>>month>>x>>day; sum=nian(year)+yue(year,month)+day; pp=sum%7;
switch(pp) { 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<<"Fiday"<<endl; break; case 6:cout<<"Saturday"<<endl; break;
} } //-------------------------------------------
int nian(int year) { int i,sum_year=0; for(i=1;i<year;i++) { if((i%4==0&&i%100!=0)||(i%400==0)) sum_year+=366; else sum_year+=365; } return (sum_year); } //------------------------------------------- int yue(int year,int month) {int yue1,day1; yue1=month-1; if((year%4==0&&year%100!=0)||(year%400==0)) { switch(yue1) { case 1:day1=31;break; case 2:day1=31+29;break; case 3:day1=31+29+31;break; case 4:day1=31+29+31+30;break; case 5:day1=31+29+31+30+31;break; case 6:day1=31+29+31+30+31+30;break; case 7:day1=31+29+31+30+31+30+31;break; case 8:day1=31+29+31+30+31+30+31+31;break; case 9:day1=31+29+31+30+31+30+31+31+30;break; case 10:day1=31+29+31+30+31+30+31+31+30+31;break; case 11:day1=31+29+31+30+31+30+31+31+30+31+30;break; case 12:day1=31+29+31+30+31+30+31+31+30+31+30+31;break; } } else { switch(yue1) { case 1:day1=31;break; case 2:day1=31+28;break; case 3:day1=31+28+31;break; case 4:day1=31+28+31+30;break; case 5:day1=31+28+31+30+31;break; case 6:day1=31+28+31+30+31+30;break; case 7:day1=31+28+31+30+31+30+31;break; case 8:day1=31+28+31+30+31+30+31+31;break; case 9:day1=31+28+31+30+31+30+31+31+30;break; case 10:day1=31+28+31+30+31+30+31+31+30+31;break; case 11:day1=31+28+31+30+31+30+31+31+30+31+30;break; case 12:day1=31+28+31+30+31+30+31+31+30+31+30+31;break; } }
return (day1); } |
|
|
|
| 日 | 一 | 二 | 三 | 四 | 五 | 六 |
---|
30 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
|
导航
统计
常用链接
留言簿(1)
随笔档案
搜索
最新评论
阅读排行榜
评论排行榜
|
|