#include <stdio.h>
int year,month,day,ans;
int main(){
while(scanf("%d/%d/%d",&year,&month,&day)!=EOF){
ans=0;
switch(month-1){ //这里需要减一,加的是上个月的时间,本月的只加天数
case 11: ans+=30; //case必须倒着写,因为没有遇到break,程序会加上其下属的值
case 10: ans+=31;
case 9: ans+=30;
case 8: ans+=31;
case 7: ans+=31;
case 6: ans+=30;
case 5: ans+=31;
case 4: ans+=30;
case 3: ans+=31;
case 2: if((year%4==0&&year%100!=0)||(year%400==0)) ans+=29;
else ans+=28;
case 1: ans+=31;
}
ans+=day;
printf("%d\n",ans);
}
return 0;
}
hdu 2005 第几天?
最新推荐文章于 2018-12-09 22:31:10 发布