• HDU


    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

    代码:

    #include<iostream>
    
    using namespace std;
    
    bool m[] = {false,true,false,true,false,true,false,true,true,false,true,false,true};
    char b[7][10]={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
    
    int main()
    {
    	int year,month,day;
    	while(cin>>year>>month>>day)
    	{
    		if((year == 0 || month == 0 || day == 0) || (month == 2 && day>29) || (!m[month] && day == 31))
    		{
    		    printf("illegal
    ");
    		    continue;
    		}
    		if(!(year%4 == 0 && year%100 != 0 ||year%400 == 0)&&month == 2 && day == 29)
    		{
    			printf("illegal
    ");
    		    continue;
    		} 
    		if(month<3)
    		{
    			year-=1;
    			month+=12;
    		}
    		int c= int(year/100),y = year-100*c;
    		int w= int(c/4)-2*c+y+int(y/4) + (26*(month+1)/10)+day-1;
    		w=(w%7+7)%7;
    		cout<<b[w]<<endl;
    	}
    	return 0;
    }
  • 相关阅读:
    网页Tab控件
    ivy在eclipse中的重新加载
    es删除文档或者删除索引
    es修改数据
    es中插入数据
    创建es索引-格式化和非格式化
    MySQL常用字符串函数
    python各种类型转换
    python 3.4读取输入参数
    python异常捕获异常堆栈输出
  • 原文地址:https://www.cnblogs.com/vocaloid01/p/9514005.html
Copyright © 2020-2023  润新知