#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<stdlib.h>
int main() {
int x=0, y=0,day=0;
printf("请输入年份:\n");
scanf("%d",&y);
printf("您输入的年份是:%d年\n", y);
printf("请输入月份:\n");
scanf("%d", &x);
printf("您输入的月份是:%d月\n", x);
switch (x) {
case 1:day = 31; printf("%d年%d月有%d天\n",y,x,day); break;
case 3:day = 31; printf("%d年%d月有%d天\n", y, x, day); break;
case 5:day = 31; printf("%d年%d月有%d天\n", y, x, day); break;
case 7:day = 31; printf("%d年%d月有%d天\n", y, x, day); break;
case 8:day = 31; printf("%d年%d月有%d天\n", y, x, day); break;
case 10:day = 31; printf("%d年%d月有%d天\n", y, x, day); break;
case 12:day = 31; printf("%d年%d月有%d天\n", y, x, day); break;
case 4:day = 30;printf("%d年%d月有%d天\n", y, x, day); break;
case 6:day = 30; printf("%d年%d月有%d天\n", y, x, day); break;
case 9:day = 30; printf("%d年%d月有%d天\n", y, x, day); break;
case 11:day = 30; printf("%d年%d月有%d天\n", y, x, day); break;
case 2:
if (y%4==0||y%400==0) {
day = 29;
printf("%d年%d月有%d天\n", y, x, day); break;
}
else {
day = 28;
printf("%d年%d月有%d天\n", y, x, day); break;
};
default:printf("error!\n");
}
return 0;
}
|