CCF_ 201509-2_日期计算

水。

 

#include<iostream>
#include<cstdio>
using namespace std;
int a[][13] = {{0,31,28,31,30,31,30,31,31,30,31,30,31},{0,31,29,31,30,31,30,31,31,30,31,30,31}};
int main()
{
    int y,d;
    cin >> y >> d;
    int choose = 0;
    if(!(y%4) && y%100 || !(y%400)) choose = 1;
    int m = 1;
    while(d > a[choose][m])
    {
        d -= a[choose][m];
        m++;
    }
    cout << m << endl << d << endl;
    return 0;
}

 

posted @ 2016-09-06 02:39  zzzzzzzzhu  阅读(520)  评论(0编辑  收藏  举报