//给出年月日输出下一天的日期
#include<iostream>
using namespace std;
const int num[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
bool check(int x)//判断是否是闰年
{
if((x%4==0&&x%100!=0)||x%400==0)
return true;
return false;
}
void f(int &a,int &b,int &c)
{
c++;
if(c>num[b])
{
if(b==2&&check(a)&&c==29)
return;
b++;
c=1;
if(b>12)
{
a++;
b=1;
}
}
return;
}
int main()
{
int year,month,date;
while(cin>>year>>month>>date)
{
f(year,month,date);
cout<<year<<" "<<month<<" "<<date<<endl;
}
return 0;
}
给出年月日输出下一天的日期
最新推荐文章于 2023-03-04 11:03:20 发布