- #include <stdio.h>
- int printdate(int year,int month,int day)
- {
- int d;
- if((year%4==0&&year%100!=0)||year%400==0)
- d=29;
- else
- d=28;
- switch(month)
- {
- case 1:if(day<=31)
- printf("January %d,%d\n",day,year);
- else
- printf("错误\n");
- break;
- case 2:if(day<=d)
- printf("February %d,%d\n",day,year);
- else
- printf("错误\n");
- break;
- case 3:if(day<=31)
- printf("March %d,%d\n",day,year);
- else
- printf("错误\n");
- break;
- case 4:if(day<=30)
- printf("April %d,%d\n",day,year);
- else
- printf("错误\n");
- break;
- case 5:if(day<=31)
- printf("May %d,%d\n",day,year);
- else
- printf("错误\n");
- break;
- case 6:if(day<=30)
- printf("June %d,%d\n",day,year);
- else
- printf("错误\n");
- break;
- case 7:if(day<=31)
- printf("July %d,%d\n",day,year);
- else
- printf("错误\n");
- break;
- case 8:if(day<=30)
- printf("August %d,%d\n",day,year);
- else
- printf("错误\n");
- break;
- case 9:if(day<=31)
- printf("September %d,%d\n",day,year);
- else
- printf("错误\n");
- break;
- case 10:if(day<=30)
- printf("October %d,%d\n",day,year);
- else
- printf("错误\n");
- break;
- case 11:if(day<=31)
- printf("November %d,%d\n",day,year);
- else
- printf("错误\n");
- break;
- case 12:if(day<=30)
- printf("December %d,%d\n",day,year);
- else
- printf("错误\n");
- break;
- }
- }
- int main()
- {
- int y,m,d;
- while(1)
- {
- printf("请输入年月日: ");
- scanf("%d%d%d",&y,&m,&d);
- printdate(y,m,d);
- }
- }
第三章三十六题
最新推荐文章于 2021-05-09 23:04:39 发布