标签:
1 #include<cstdio> 2 using namespace std; 3 4 int a[13]={0,31,28,31,30,31,30,31,31,30,31,30,31}; 5 int b[13]={0,31,29,31,30,31,30,31,31,30,31,30,31}; 6 7 bool judge(int year) 8 { 9 if(year%4==0&&year%100!=0||year%400==0) 10 return true; 11 return false; 12 } 13 14 int main() 15 { 16 int i; 17 int year,month,day,count; 18 while(scanf("%d/%d/%d",&year,&month,&day)!=EOF) 19 { 20 count=0; 21 bool flag=judge(year); 22 if(flag) 23 { 24 for(i=1;i<month;i++) 25 count+=b[i]; 26 count+=day; 27 } 28 else 29 { 30 for(i=1;i<month;i++) 31 count+=a[i]; 32 count+=day; 33 } 34 printf("%d\n",count); 35 } 36 return 0; 37 }
标签:
原文地址:http://www.cnblogs.com/homura/p/4674231.html