zoukankan      html  css  js  c++  java
  • 杭电2133What day is it

    给你个日期 问是星期几        知道1 1 1是周1就行了

    #include <iostream>
    #include <cstdio>
    using namespace std;
    int arr[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};
    char str[7][100] = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"};
    bool run(int x);
    int main()
    {
        int a,b,c,i,j,sum = 0;
        int Y = 2007,M = 11,D = 17,R = 6;
        for(i =0; i < 2007; ++i)
            if(run(i))
        while(scanf("%d%d%d",&a,&b,&c) != EOF)
        {
            long long sum = 0;
            if(b == 0 || c == 0 || (b == 2 && c > 29 && run(a)) || (b == 2 && c > 28 && !run(a)) || (c > arr[b] && b != 2) )
            {
                cout << "illegal" << endl;
                continue;
            }
            for(i = 1; i < a; ++i)
            {
                if(run(i)) sum += 366;
                else sum += 365;
            }
            for(i = 1; i <= b-1; ++i)
            {
                sum += arr[i];
            }
            if(run(a) && b > 2)
                sum ++;
            sum += c;
            sum= sum%7;
    //        if(!sum) sum = 7;
            cout << str[sum] << endl;
        }
    }
    bool run(int x)
    {
        if((x % 4 == 0 && x % 100 != 0)|| x%400 == 0)
            return true;
        else
            return false;
    }

  • 相关阅读:
    java线程
    面向切面编程
    控制反转IOC与依赖注入DI
    phpexecel 导入导出,格式
    PHPExcel设置数据格式的几种方法
    九度oj 题目1416:猴子吃坚果
    九度oj 题目1397:查找数段
    poj 1065 Wooden Sticks
    poj 3181 Dollar Dayz
    poj 1742 Coins
  • 原文地址:https://www.cnblogs.com/mltang/p/8695564.html
Copyright © 2011-2022 走看看