题解

1 条题解

  • 0
    @ 2019-05-10 20:33:19

    #include<bits/stdc++.h>
    using namespace std;
    int date1,date2;
    int month,day,sum,dt1,dt2;
    bool check(int date)
    {
    int a[5],k=date;
    for(int i=1;i<=4;i++)
    {
    a[i]=k%10;
    k/=10;
    }
    month=a[1]*10+a[2];
    day=a[3]*10+a[4];
    if((month==1||month==3||month==5||month==7||month==8||month==10||month==12)&&day<=31)return 1;
    if((month==4||month==6||month==9||month==11)&&day<=30)return 1;
    if((date%400==0|| (date%4==0&&date%100!=0))&&day<=29&&month==2)return 1;
    if(!(date%400==0|| (date%4==0&&date%100!=0))&&day<=28&month==2)return 1;
    return 0;
    }
    int main()
    {
    cin>>date1>>date2;
    dt1=date1/10000;dt2=date2/10000;
    for(int i=dt1;i<=dt2;i++)
    {
    if(check(i))sum++;
    }
    cout<<sum;
    return 0;
    }

  • 1

信息

ID
1006
难度
7
分类
(无)
标签
递交数
25
已通过
6
通过率
24%
上传者