1 条题解

  • 0
    #include<iostream>
    using namespace std;
    const int N=13;
    bool isleap(int n)
    {
        if(n%4==0&&n%100!=0||n%400==0) return true;
        else return false;
    }
    int main()
    {
        int year,month,day;cin>>year>>month>>day;
        int a[N]={0,31,28,31,30,31,30,31,31,30,31,30,31};
        if(isleap(year)==true) a[2]=29;
        int x;cin>>x;
        while(x!=0)
        {
            day++;
            if(day>a[month]){
                day=1;
                month++;
            }
            if(month>12){
                month=1;
                year++;
                if(isleap(year)==true) a[2]=29;
                else a[2]=28;
            }
            x--; 
        }
        cout<<year<<" "<<month<<" "<<day;
        return 0;
    }
    
    
  • 1

信息

ID
1109
难度
1
分类
(无)
标签
递交数
45
已通过
33
通过率
73%
上传者