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. HDU 3836 Equivalent SetsTarjan+缩点)

    Problem Description To prove two sets A and B are equivalent, we can first prove A is a subset of B, ...

  2. python网络爬虫学习笔记

    python网络爬虫学习笔记 By 钟桓 9月 4 2014 更新日期:9月 4 2014 文章文件夹 1. 介绍: 2. 从简单语句中開始: 3. 传送数据给server 4. HTTP头-描写叙述 ...

  3. Eclipse——热键&amp;Help

    版权声明:本文博主原创文章.博客,未经同意不得转载.

  4. 流量计算-Jstorm提交Topology过程(下一个)

    马上部分流量计算-Jstorm提交Topology过程(上), 5.上篇任务已经ServiceHandler.submitTopologyWithOpts()方法.在该方法中,会实例化一个Topolo ...

  5. webclient下载文件 带进度条

    private void button1_Click(object sender, EventArgs e) { doDownload(textBox1.Text.Trim()); } private ...

  6. ProgressMonitorInputStream

    Swing类包中有一个很有用的流过滤器,ProgressMonitorInputStream,它可以自动弹出一个对话框,监视已经读取了多少流. 进度监视器流使用InputStream类的availab ...

  7. 一个简单的RPC框架

    一个 系统模型 二.数据库代码实现 1. mkdir database cd database vim dbInit.c /* * * Database Init tool * */ #include ...

  8. [Ext JS 4] 实战Chart 协调控制(单一的坐标,两个坐标)

    前言

  9. UVA 1358 - Generator(dp+高斯消元+KMP)

    UVA 1358 - Generator option=com_onlinejudge&Itemid=8&page=show_problem&category=524& ...

  10. MyEclipse—怎样在MyEclipse中创建servlet3.0

    servlet3.0随着Java EE6规范一起公布,那么怎样在MyEclipse中创建3.0版的servlet呢? 1.启动MyEclipse.获得下图: 2.点击上图"File" ...