• 2015 编程之美 资格赛 第一题 hihocoder 区间闰年 2月29 数量 模拟题


    #include <string.h>   ->memset()的头文件

    http://hihocoder.com/contest/msbop2015qual/problem/1

    #include <iostream>
    #include <string>
    #include <stdio.h>
    #include <memory>
    #include <string.h>
    using namespace std;
    string m[]={"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November" , "December"};
    class year2
    {
    public :
        int year;
        string mouth;
        int day;
        int i_mouth;
        int special;
        void tran_mouth()
        {
            for(int i=0;i<12;i++)
                if(mouth==m[i])
                    i_mouth=i+1;
        };
        void cal()
        {
            special=year/4-year/100+year/400;
        };
        bool is_special()
        {
            if(year%400==0||(year%4==0&&year%100!=0))
            {
                return true;
            }
            return false;
        };
        bool before_include_special()
        {
            if(i_mouth<2||(i_mouth==2&&day<=29))
                return true;
            else 
                return false;
        };
        bool before_special()
        {
            if(i_mouth<2||(i_mouth==2&&day<29))
                return true;
            else 
                return false;
        };
    };
    int main()
    {
        int T;
        int Case=0;
        cin>>T;
        
        while(T--)
        {
            char t;
            Case++;
            year2 start;
            year2 end;
            cin>>start.mouth;
            cin>>start.day;
            cin>>t;
            cin>>start.year;
    
            cin>>end.mouth;
            cin>> end.day;
            cin>> t;
            cin>> end.year;
    
            start.tran_mouth();
            start.cal();
            end.tran_mouth();
            end.cal();
    
            int ans= end.special- start.special;
            if(start.is_special()&&start.before_include_special())
            {
                ans+=1;
            }
            if(end.is_special()&&end.before_special())
            {
                ans-=1;
            }
            cout<<"Case #"<<Case<<": "<<ans<<endl;
        }
    
    }
  • 相关阅读:
    WebView
    dpdpipxptem单位长度理解
    js跨域访问
    JS&CSS压缩工具YUICompressor
    IIS7.5站点配置
    Jscript运行时错误:没有权限
    控制HttpContext为null
    JSON数组成员反序列化
    Linux 系统默认运行级别设定
    环境搭建常用工具
  • 原文地址:https://www.cnblogs.com/tjsudys/p/4435137.html
Copyright © 2020-2023  润新知