Calendar
来源:互联网 发布:淘宝店铺月销量怎么看 编辑:程序博客网 时间:2024/05/29 11:01
Description
A calendar is a system for measuring time, from hours and minutes, to months and days, and finally to years and centuries. The terms of hour, day, month, year and century are all units of time measurements of a calender system.
According to the Gregorian calendar, which is the civil calendar in use today, years evenly divisible by 4 are leap years, with the exception of centurial years that are not evenly divisible by 400. Therefore, the years 1700, 1800, 1900 and 2100 are not leap years, but 1600, 2000, and 2400 are leap years.
Given the number of days that have elapsed since January 1, 2000 A.D, your mission is to find the date and the day of the week.
According to the Gregorian calendar, which is the civil calendar in use today, years evenly divisible by 4 are leap years, with the exception of centurial years that are not evenly divisible by 400. Therefore, the years 1700, 1800, 1900 and 2100 are not leap years, but 1600, 2000, and 2400 are leap years.
Given the number of days that have elapsed since January 1, 2000 A.D, your mission is to find the date and the day of the week.
Input
The input consists of lines each containing a positive integer, which is the number of days that have elapsed since January 1, 2000 A.D. The last line contains an integer −1, which should not be processed.
You may assume that the resulting date won’t be after the year 9999.
You may assume that the resulting date won’t be after the year 9999.
Output
For each test case, output one line containing the date and the day of the week in the format of "YYYY-MM-DD DayOfWeek", where "DayOfWeek" must be one of "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday" and "Saturday".
Sample Input
1730174017501751-1
Sample Output
2004-09-26 Sunday2004-10-06 Wednesday2004-10-16 Saturday2004-10-17 Sunday#include <iostream>#include<string>using namespace std;int main(){int t,i;string xing;while(cin>>t,t>=0){i=t%7;t++;int nian=2000,yun[13],yue;switch(i){case 1:xing="Sunday";break;case 2:xing="Monday";break;case 3:xing="Tuesday";break;case 4:xing="Wednesday";break;case 5:xing="Thursday";break;case 6:xing="Friday";break;case 0:xing="Saturday";break;default:break;}while(t>=366){if(nian%4==0&&nian%100!=0||nian%400==0) {if(t==366)break;else t-=366;nian++;}else{t-=365;nian++;}}yun[1]=yun[5]=yun[3]=yun[7]=yun[8]=yun[10]=yun[12]=31;yun[4]=yun[6]=yun[9]=yun[11]=30;if(nian%4==0&&nian%100!=0||nian%400==0) yun[2]=29;else yun[2]=28;for(i=1;i<=12;i++){ if(t<=yun[i])break; else t=t-yun[i];}yue=i;if(yue<10&&t>=10)cout<<nian<<"-0"<<yue<<"-"<<t;if(yue<10&&t<10)cout<<nian<<"-0"<<yue<<"-0"<<t;if(yue>=10&&t<10)cout<<nian<<"-"<<yue<<"-0"<<t;if(yue>=10&&t>=10)cout<<nian<<"-"<<yue<<"-"<<t;cout<<" "<<xing<<endl;}return 0;}
0 0
- calendar
- calendar
- Calendar
- Calendar
- calendar
- Calendar
- Calendar
- Calendar
- Calendar
- Calendar
- Calendar
- Calendar
- Calendar
- Calendar
- Calendar
- calendar
- Calendar
- Calendar
- 对象池技术
- Android显示Log信息(带行号,类名,方法名)
- 算法导论学习笔记-5.2 指示器随机变量
- [开源夏令营][三] 研究 Docker remote API 的前期准备
- win8系统下安装 .NET Framework 3.5出现错误代码:0x800F0906
- Calendar
- java操作Oracle类型XMLType总结二:使用Mybatis
- 深入浅出工厂模式
- mssql-数字转为中文大写函数
- git 命令之git rebase 最详细用法 .
- 算法导论学习笔记-5.3 随机算法
- 获取Wifi相关信息
- php5.3非线程安全下载-win
- linux c++ 管道操作