P5690

· · 个人记录

这道题,唉...

一言难尽(我...直接裂开ε(┬┬﹏┬┬)3)

其实这道题只要开个数组储存每个月的天数,就特简单(默默打表的我30min后才意识到...┭┮﹏┭┮)

代码...

#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int ans=0,f[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};//就是它!!!(害得我浪费了30min,嘤嘤嘤...) 
    int month=(s[0]-48)*10+s[1]-48,day=(s[3]-48)*10+s[4]-48;//用ASCLL码转换成数字 
    if(month>=13||month<=0)
    {
        ans++;
        if(month>=20&&month%10!=2)
        {
            if(month%10!=0)
            month=month%10;
            else
            month=10;
        }
        else
        month=12;
    }//判断月份 
    if(day>f[month]||day<=0)
    ans++;//判断日期
    cout<<ans;
    return 0;
}

写个题解,纪念一下,啦啦啦~~~