CCF CSP 201509-2 日期计算
思路:
用数组存对应月份的日期
代码:
#include<bits/stdc++.h>
using namespace std;
#define rpn(i,n) for(int i=1;i<=n;i++)
int cal[13]={0,31,0,31,30,31,30,31,31,30,31,30,31};
int main(){
int y,d;
cin>>y>>d;
if((!(y%4)&&y%100)||!(y%400)) cal[2]=29;
else cal[2]=28;
int mon=1;
rpn(i,12){
if(d>cal[i]){
mon++;
d-=cal[i];
}else break;
}
cout<<mon<<'\n'<<d;
return 0;
}