#include <stdio.h>int main() { int year,month,day,sum; char a; loop: do{ printf("input year,month,day\n"); scanf("%d.%d.%d",&year,&month,&day); if(month>=1&&month<=12&&day>=1&&day<=31) { switch(month) { case 1:sum=day;printf("%d年%d月%d日是该年的第%d天\n",year,month,day,sum);break; case 2:sum=day+31;printf("%d年%d月%d日是该年的第%d天\n",year,month,day,sum);break; case 3: if(year%400==0||(year%4==0&&year%100!=0)) { sum=day+60;printf("%d年%d月%d日是该年的第%d天\n",year,month,day,sum);break;}else { sum=day+59;printf("%d年%d月%d日是该年的第%d天\n",year,month,day,sum);break;} case 4:sum=day+90;printf("%d年%d月%d日是该年的第%d天\n",year,month,day,sum);break; case 5:sum=day+120;printf("%d年%d月%d日是该年的第%d天\n",year,month,day,sum);break; case 6:sum=day+151;printf("%d年%d月%d日是该年的第%d天\n",year,month,day,sum);break; case 7:sum=day+181;printf("%d年%d月%d日是该年的第%d天\n",year,month,day,sum);break; case 8:sum=day+212;printf("%d年%d月%d日是该年的第%d天\n",year,month,day,sum);break; case 9:sum=day+243;printf("%d年%d月%d日是该年的第%d天\n",year,month,day,sum);break; case 10:sum=day+273;printf("%d年%d月%d日是该年的第%d天\n",year,month,day,sum);break; case 11:sum=day+304;printf("%d年%d月%d日是该年的第%d天\n",year,month,day,sum);break; case 12:sum=day+334;printf("%d年%d月%d日是该年的第%d天\n",year,month,day,sum);break; default:printf("一年只有12个月哟~\n");break; } printf("Do you want to continue?y/n\n"); scanf(" %c",&a); } else { printf("Error\n"); goto loop; } }while(a=='y'||a=='Y'); return 0;}无论闰年非闰年每年的8月8号都显示是220天,其实闰年是221天,也就是判断不了闰年,求解
添加回答
举报
0/150
提交
取消