• 杭电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;
    }

  • 相关阅读:
    高并发 内核优化
    mysql 读写分离
    Jmeter使用入门
    Jenkins+Jmeter+Ant接口持续集成
    Android客户端稳定性测试——Monkey
    SVN客户端项目递归删除.svn目录
    Windows 下 php5+apache+mysql5 手工搭建笔记
    熟悉常用的Linux操作
    C语言文法
    词法分析实验报告
  • 原文地址:https://www.cnblogs.com/mltang/p/8695564.html
Copyright © 2020-2023  润新知