HDU 2005 第几天?

 1 #include<stdio.h>
 2 int main()
 3 {
 4     int year,month,day,i;
 5     while(scanf("%d/%d/%d",&year,&month,&day)!=EOF) 
 6       { 
 7          i=0;
 8          switch(month-1)
 9           {
10             case 11: i+=30;
11             case 10: i+=31;
12             case 9:  i+=30;
13              case 8:  i+=31;
14             case 7:  i+=31;
15             case 6:  i+=30;
16             case 5:  i+=31;
17             case 4:  i+=30;
18             case 3:  i+=31;
19             case 2:  if((year%4==0&&year%100!=0)||(year%400==0))
20                      i+=29;
21                      else
22                      i+=28;
23             case 1:  i+=31;
24           }
25         i+=day;
26         printf("%d\n",i);
27      }
28      return 0;
29 }

posted on 2012-08-03 17:50  mycapple  阅读(1443)  评论(0编辑  收藏  举报

导航