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 ;
}

随机推荐

  1. 抓取csdn上的各类别的文章 (制作csdn app 二)

    转载请表明出处:http://blog.csdn.net/lmj623565791/article/details/23532797 这篇博客接着上一篇(Android 使用Fragment,View ...

  2. 应用层协议系列(两)——HTTPserver之http协议分析

    上一篇文章<抄nginx Httpserver设计与实现(一)--多进程和多通道IO现>中实现了一个仿照nginx的支持高并发的server.但仅仅是实现了port监听和数据接收.并没有实 ...

  3. [LeetCode118]Pascal's Triangle

    题目: Given numRows, generate the first numRows of Pascal's triangle. For example, given numRows = 5,R ...

  4. hdu 4920 Matrix multiplication(矩阵乘法)2014多培训学校5现场

    Matrix multiplication                                                                           Time ...

  5. Java读取图像和网络存储

    该公司最近在搞一个Web工程,需要下载网络图片,那么既然恢复了一些最基本的东西.数据传输不同的流,简单,很容易下载网络打破了样品的图片,代码非常easy.贡献给大家! 结论,图片主要就四步: 1:拿到 ...

  6. 什么是Cyclomatic Complexity(圈复杂度)?

    Campwood Software SourceMonitor Version 3.5 The freeware program SourceMonitor lets you see inside y ...

  7. CentOS-6.5-x86_64 最小化安装后,怎样安装 man 程序?

    CentOS-6.5-x86_64 最小化安装后.怎样安装man 程序? CentOS-6.5-x86_64 最小化安装后,没有man 程序,没它还真的不方便. man 是 manual(手冊)的意思 ...

  8. Python 基金会 —— 模块和包简介

    一.模块(Module) 1.模块的作用      在交互模式下输出的变量和函数定义,一旦终端重新启动后,这些定义就都不存在了,为了持久保存这些变量.函数等的定义,Python中引入了模块(Modul ...

  9. ext Window点击右上角的关闭(Xbutton)加入监控事件

    使用场景:关闭window的时候添加监听事件. 正确的使用方式: addwin = new Ext.Window({ title : '新增', closable : true, width : 50 ...

  10. Team Foundation Server 2015使用教程--tfs用户账号切换