#include<iostream> using namespace std; bool isleap(int year)//判断闰年 { if((year%4==0&&year%100!=0)||(year%400==0)) return true; return false; } int main() { int M,year,month,day,hour,minute,second,th,tm,ts; while(cin>>M) { scanf("%d-%d-%d %d:%d:%d",&year,&month,&day,&hour,&minute,&second); th=M/3600;M%=3600;tm=M/60;M%=60;ts=M;hour+=th;minute+=tm;second+=ts; minute+=second/60;second%=60;hour+=minute/60;day+=hour/24;hour%=24;minute%=60; while(true) { if(month==2)//如果为2月份 { if(isleap(year)) { if(day<=29) break; day-=29;month++; } else { if(day<=28) break; day-=28;month++; } } else if(month==1||month==3||month==5||month==7||month==8||month==10||month==12) { if(day<=31) break; day-=31;month++; if(month>12){month-=12;year++;} } else { if(day<=30) break; day-=30;month++; } } printf("%d-%02d-%02d %02d:%02d:%02d\n",year,month,day,hour,minute,second); } return 0; }
//几组测试数据
/* 86400 2008-04-27 12:00:00 2008-04-28 12:00:00 86400 2008-04-28 12:00:00 2008-04-29 12:00:00 86400 2008-02-29 12:00:00 2008-03-01 12:00:00 500000000 2008-01-01 00:00:00 2023-11-05 00:53:20 86400 2008-12-31 12:00:00 2009-01-01 12:00:00 500000000 2017-12-31 23:59:59 2033-11-05 00:53:19 */
|