文章
60
粉丝
361
获赞
43
访问
524.6k
#include<iostream>
#include <string>
using namespace std;
int main()
{
int month[2][13]=
{{0,31,28,31,30,31,30,31,31,30,31,30,31},
{0,31,29,31,30,31,30,31,31,30,31,30,31}
};
int m;
int year,mon,day,cnt;
scanf("%d",&m);
while(m>0)
{
scanf("%d %d %d %d",&year,&mon,&day,&cnt);
while(cnt>0)
{
//判断闰年
int flag=0;
if((year%400==0)||(year%4==0)&&(year%100!=0))
flag=1;
else
flag=0;
day++;
if(day>month[flag][mon])
{
day=1;
mon++;
if(mon>12)
{
mon=1;
year++;
}
}
cnt--;
}
printf("%d-%02d-%02d\n",year,mon,day);
m--;
}
//system("pause");
return 0;
}
登录后发布评论
暂无评论,来抢沙发