首页 > 代码库 > CCF_ 201509-2_日期计算

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;}

 

CCF_ 201509-2_日期计算