/* Note:My name is zxf */ #include "stdio.h" void main() { int year,month,day,sumdays,maxdays,xx,yy,zz,yueshu; int x; printf("请输入一个年份:"); xx: x=scanf("%d",&year); if(x!=1||year<1990||year>9999) { printf("年份输入有误,请重输:"); fflush(stdin); goto xx; } x=0; printf("请输入一个月份:"); yy: x=scanf("%d",&month); if(x!=1||month<1||month>12) { printf("输入月份有误,请重输:"); fflush(stdin); goto yy; } x=0; printf("请输入一个号数:"); zz: x=scanf("%d",&day); switch(month) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: maxdays=31;break; case 4: case 6: case 9: case 11: maxdays=30;break; case 2: if(year%4==0&&year%100!=0||year%400==0) maxdays=29; else maxdays=28;break; } if(x!=1||day<1||day>maxdays) { printf("输入号数有误,请重输:"); fflush(stdin); goto zz ; } for(yueshu=1;month-1>=yueshu;yueshu++) { switch(yueshu) { case 1: case 3: case 5: case 7: case 8: case 10: case 12: maxdays=31;break; case 4: case 6: case 9: case 11: maxdays=30;break; case 2: if(year%4==0&&year%100!=0||year%400==0) maxdays=29; else maxdays=28;break; } sumdays+=maxdays; } sumdays+=day; printf("%d年%d月%d日是第%d天",year,month,day,sumdays); }