CSP题解|201509-2 日期计算|100分
#include <bits/stdc++.h> using namespace std; int main() { int year,dayNum; cin>>year>>dayNum; int month[]={0,31,28,31,30,31,30,31,31,30,31,30,31}; if((year%400==0)||(year%4==0&&year%100!=0)) month[2]++; for(int i =1;i<=12;i++){ if(dayNum>month[i]){ dayNum-=month[i]; }else{ cout<<i<<endl<<dayNum<<endl; break; } } }
牛牛有原题