题解 | #打印日期#
打印日期
https://www.nowcoder.com/practice/b1f7a77416194fd3abd63737cdfcf82b
#include <iostream> using namespace std; int main() { int y = 0; int n = 0; int array[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31}; while(cin >> y >> n) { if(((y%4==0) && (y%100 !=0)) || (y % 400 == 0)) { array[2] = 29; } for(int i = 1;i < 13;++i) { if(n > array[i]) { n -= array[i]; } else { printf("%04d-%02d-%02d\n",y,i,n); break; } } array[2] = 28; } return 0; }