#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;
    }

}

 

posted on 2015-04-17 15:46  海暗  阅读(374)  评论(0编辑  收藏  举报