关于任意年份月份日期的天数问题
#include<stdio.h> int main() { int year; int month; //该年的第几个月 int day; //该月的第几天 int sum; //该年的第多少天 int Jan = 31; int Feb; int March = 31; int April = 30; int May = 31; int June = 30; int July = 31; int Aug = 31; int Sep = 30; int Oct = 31; int Nov = 30; int Dce = 31; // printf("请输入年份:\n"); scanf_s("%d", &year); if ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0) //判断是否闰年 { Feb = 29; } else { Feb = 28; } // //选择并判断该月份的天数 printf("请输入月份:\n"); scanf("%d", &month); switch (month) { case 1:Jan; break; case 2:Feb; break; case 3:March; break; case 4:April; break; case 5:May; break; case 6:June; break; case 7:July; break; case 8:Aug; break; case 9:Sep; break; case 10:Oct : break; case 11:Nov; break; case 12:Dce; break; default:printf("%s", "请输入正确的月份!\n"); } // printf("请输入日期:\n"); scanf("%d", &day); if (month = 1 ) { if (day <=31) sum = day; } else { printf("请输入正确的日期!\n"); } if (month = 2) { if (day <= 29||day <=28) sum = Jan + day; } else { printf("请输入正确的日期!\n"); } if (month = 3) { if (day <= 31) sum = Jan + Feb + day; } else { printf("请输入正确的日期!\n"); } if (month = 4) { if (day <= 30) sum = Jan + Feb + March + day; } else { printf("请输入正确的日期!\n"); } if (month = 5) { if (day <= 31) sum = Jan + Feb + March + April + day; } else { printf("请输入正确的日期!\n"); } if (month = 6) { if (day <= 30) sum = Jan + Feb + March + April + May + day; } else { printf("请输入正确的日期!\n"); } if (month = 7) { if (day <= 31) sum = Jan + Feb + March + April + May + June + day; } else { printf("请输入正确的日期!\n"); } if (month = 8) { if (day <= 31) sum = Jan + Feb + March + April + May + June + July + day; } else { printf("请输入正确的日期!\n"); } if (month = 9) { if (day <= 30) sum = Jan + Feb + March + April + May + June + July + Aug + day; } else { printf("请输入正确的日期!\n"); } if (month = 10) { if (day <= 31) sum = Jan + Feb + March + April + May + June + July + Aug + Sep + day; } else { printf("请输入正确的日期!\n"); } if (month = 11) { if (day <= 30) { sum = Jan + Feb + March + April + May + June + July + Aug + Sep + Oct + day; } else { printf("请输入正确的日期!\n"); } } if (month = 12) { if (day <= 31) { sum = Jan + Feb + March + April + May + June + July + Aug + Sep + Oct + Dce + day; } else { printf("请输入正确的日期!"); } } // printf("%d年的%d月%d日是该年的第%d天", year,month,day,sum); return 0; }
每次输入的月份都会输出为12,请问一下哪边出了问题?