#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個(gè)月喲~\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;}無(wú)論閏年非閏年每年的8月8號(hào)都顯示是220天,其實(shí)閏年是221天,也就是判斷不了閏年,求解
1 回答
- 1 回答
- 0 關(guān)注
- 1539 瀏覽
添加回答
舉報(bào)
0/150
提交
取消