testing-repository/cpp/algorithms/problem6.cpp

53 lines
1.3 KiB
C++
Raw Normal View History

2021-11-20 22:12:12 +08:00
//http://acm.hdu.edu.cn/showproblem.php?pid=2005
2021-11-19 20:06:45 +08:00
#include <cstdio>
int main(int argc,char ** argv){
int year,month,day,sum_day=0;
while (scanf("%d/%d/%d",&year,&month,&day)!=EOF)
{
2021-11-20 22:12:12 +08:00
sum_day=0;
2021-11-19 20:06:45 +08:00
switch(month){
case 1:
2021-11-20 22:12:12 +08:00
sum_day = day;
2021-11-19 20:06:45 +08:00
break;
case 2:
2021-11-20 22:12:12 +08:00
sum_day = 31+day;
2021-11-19 20:06:45 +08:00
break;
case 3:
2021-11-20 22:12:12 +08:00
sum_day = 59+day;
break;
2021-11-19 20:06:45 +08:00
case 4:
2021-11-20 22:12:12 +08:00
sum_day = 90+day;
break;
2021-11-19 20:06:45 +08:00
case 5:
2021-11-20 22:12:12 +08:00
sum_day = 120+day;
break;
2021-11-19 20:06:45 +08:00
case 6:
2021-11-20 22:12:12 +08:00
sum_day = 151+day;
break;
2021-11-19 20:06:45 +08:00
case 7:
2021-11-20 22:12:12 +08:00
sum_day = 181+day;
break;
2021-11-19 20:06:45 +08:00
case 8:
2021-11-20 22:12:12 +08:00
sum_day = 212+day;
break;
2021-11-19 20:06:45 +08:00
case 9:
2021-11-20 22:12:12 +08:00
sum_day = 243+day;
break;
2021-11-19 20:06:45 +08:00
case 10:
2021-11-20 22:12:12 +08:00
sum_day = 273+day;
break;
2021-11-19 20:06:45 +08:00
case 11:
2021-11-20 22:12:12 +08:00
sum_day = 304+day;
break;
2021-11-19 20:06:45 +08:00
case 12:
2021-11-20 22:12:12 +08:00
sum_day = 334+day;
break;
}
if(year%4 == 0 && year%100 != 0 && month > 2){
sum_day += 1;
2021-11-19 20:06:45 +08:00
}
2021-11-20 22:12:12 +08:00
printf("%d\n",sum_day);
2021-11-19 20:06:45 +08:00
}
return 0;
}