#include<iostream>
using namespace std;

int main(){
     int year,month,day,t;//t是中间变量 
     cout << "请输入年月日\n" ; 
     cin >> year >> month >> day;
    switch(month){
        case 2 :
        if(year % 400 == 0||(year % 4 ==4 && year % 100 !=0)){
          t=29;
          }
    else t = 28; //判断是不是闰年 
        break;
        case 1:  case 3: case 5: case 7: case 8:  case 10 : case 12:
        t = 31;
        break;
 
    default :t = 30;

     break;
}
    
    
       
    day++;
    if (day > t){
        month++;
        day = 1;
    } 
    if(month > 12){
        month = 1;
        year++
    }

   cout << year << "-" << month << "-" << day << endl;
    
    return 0;

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐