zoukankan      html  css  js  c++  java
  • 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;
        }
    
    }
  • 相关阅读:
    java资料
    tomcat内存配置
    mybatis深入理解(一)之 # 与 $ 区别以及 sql 预编译
    Sturts2的国际化处理
    web.xml中如何设置配置文件的加载路径
    varchar和varchar2的区别
    IDEA 常见文件类型的图标介绍
    IDEA文件编码修改
    Debug 介绍
    IntelliJ IDEA 显示行号方法
  • 原文地址:https://www.cnblogs.com/tjsudys/p/4435137.html
Copyright © 2011-2022 走看看