代码如下:
#include <bits/stdc++.h>
using namespace std;
bool isleapyear(int y)
{
return (y%4==0&&y%100)||y%400==0;
}
//日期计算
int main(){
int y, d, mon, day;
cin >> y >> d;
int month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
if(isleapyear(y)){
month[2] = 29;
}
for(int i = 1; i <= 12; i++){
if(d - month[i] > 0){
d -= month[i];
}
else{
mon = i;
day = d;
break;
}
}
cout << mon << endl;
cout << day << endl;
return 0;
}