2015 1 1 15
2014 11 9 1000
2015-01-16 2017-08-05
#include<iostream> #include<cstring> #include<iomanip> #include<cmath> #include<algorithm> #include<vector> using namespace std; bool judge(int y)//判断是不是闰年 { if(y%4==0&&y%100!=0||y%400==0) return true; else return false; } int mon[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; int main() { int year,month,day; int n; while( cin>>year>>month>>day>>n) { while(n) { if(judge(year)) { mon[2]=29; } else mon[2]=28; if(day<=mon[month]) day++; if(day>mon[month]) { day=1; month++; } if(month>12) { year++; month=1; } n--; } cout<<year<<"-"; if(month<10) cout<<"0"<<month<<"-"; else cout<<month<<"-"; if(day<10) cout<<"0"<<day<<endl; else cout<<day<<endl; } }
原文:https://www.cnblogs.com/h694879357/p/12234778.html