CCF CSP 201509-2 日期计算
题目链接:http://118.190.20.162/view.page?gpid=T31
题目就是给定年份以及第几天,反推几月几号。。。水
1 #include <iostream> 2 #include <algorithm> 3 #include <string> 4 #include <cstring> 5 #include <stack> 6 #include <cstdio> 7 using namespace std; 8 int n,m,i; 9 int isRun(int x) 10 { 11 return x%400==0||(x%4==0&&x%100!=0); 12 } 13 int a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; 14 int main() 15 { 16 while(cin>>n>>m){ 17 if(isRun(n)) a[2]=29; 18 else a[2]=28; 19 for(i=0;i<13;i++){ 20 if(m>a[i]){ 21 m-=a[i]; 22 } 23 else break; 24 } 25 cout<<i<<endl; 26 cout<<m<<endl; 27 //printf("%d-%02d-%02d\n",n,i,m); 28 } 29 return 0; 30 }