What day is it
2024-10-19 12:02:26
Description
Today is Saturday, 17th Nov,2007. Now, if i tell you a date, can you tell me what day it is ?
Input
There are multiply cases. One line is one case. There are three integers, year(0<year<10000), month(0<=month<13), day(0<=day<32).
Output
Output one line. if the date is illegal, you should output "illegal". Or, you should output what day it is.
Sample Input
2007 11 17
Sample Output
Saturday
注意这题细节很多,我是从0001年01月01日为周一考虑的。
#include <iostream>
#include <stdio.h>
#include <cstring>
using namespace std;
int a[]={, , , , , , , , , , , , };
int b[]={, , , , , , , , , , , , };
char c[][]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
int panduan(int y)
{
if((y%== && y%!=) || y%==)
return ;
return ;
}
int main()
{
int y, m, d, sum, i;
while(cin>>y>>m>>d)
{
if(panduan(y))
{
if(d>b[m]||m==||d==)
{
cout << "illegal" << endl;
continue;
}
}
else
{
if(d>a[m]||m==||d==)
{
cout << "illegal" << endl;
continue;
}
}
sum=;
for (i=; i<y; ++i)
{
if(panduan(i))
sum += ;
else
sum += ; }
for(int i = ; i < m; ++i)
{
if(panduan(y))
sum += b[i];
else
sum += a[i]; }
sum+=d;
sum%=;
cout<< c[sum] << endl;
}
return ;
}
最新文章
- AM335x tscadc platform driver 相关代码跟踪
- BitCoin - BlockChain
- zTree插件之多选下拉菜单代码
- 约瑟夫问题(c++实现)
- windows进程/线程创建过程 --- windows操作系统学习
- Windows程序消息机制浅析
- redux学习笔记
- 暑假集训(1)第五弹 -----Rails(Uva514)
- ANDROID 自动生成动态表格for
- C#中的TCP通讯与UDP通讯
- python datetime时间差
- Python数据处理进阶——pandas
- P2P视频模块
- 「SDOI2017」树点涂色 解题报告
- 关于memset赋值问题
- python自动化开发-6-面向对象编程
- 实用技能之Python打包制作成EXE可执行程序
- Android之多种Bitmap效果
- Android Studio自动生成UML关系类图
- HDUOJ----1166敌兵布阵(线段树单点更新)