2 条题解

  • 0

    #include<iostream>
    using namespace std;
    int main()
    {
    int m,y,d,num,leap=0;
    cin>>y>>m>>d>>num;
    for(int i=1;i<=num;i++)
    {
    d++;
    if(y%4==0&&y%100!=0||y%400==0)
    leap=1;
    else
    leap=0;
    if(m==4||m==6||m==9||m==11)
    {

    if(d>30)
    {
    m++;
    d=1;
    }
    }
    else
    {
    if(m==2)
    {
    if(d>28+leap)
    {
    m++;
    d=1;
    }

    }
    else
    {
    if(d>31)
    {
    m++;
    d=1;
    }
    }
    }
    if(m>12)
    {
    m=1;
    y++;
    }
    }
    cout<<y<<" "<<m<<" "<<d;
    }

  • 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
分类
(无)
标签
递交数
51
已通过
38
通过率
75%
上传者