文章
79
粉丝
221
获赞
46
访问
198.4k
#include <iostream>
using namespace std;
bool Jud(int year) {
return (year % 4 == 0 && year % 100 != 0) || (year % 400 == 0);
}
const int Pm[12] = { 31,28,31,30,31,30,31,31,30,31,30,31 };
const int Rm[12] = { 31,29,31,30,31,30,31,31,30,31,30,31 };
int main() {
int y, n;
while (cin >> y >> n) {
int m, i;
for (i = 1; (Jud(y) == 0 && n - Pm[i - 1] > 0) || (Jud(y) == 1 && n - Rm[i - 1]> 0); i++) {
if (Jud(y) == 0)
n -= Pm[i - 1];
else
n -= Rm[i - 1];
}
m = i;
cout << y << "-";
if (m < 10)
cout << "0";
cout << m << "-";
if (n < 10)
cout << "0";
cout << n << endl;
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发