回复 10楼 yaobao
sum=sum+day;这句加了两遍
总有那身价贱的人给作业贴回复完整的代码
#include<stdio.h> void main() { int day, month, year, sum; printf("\nplease input year,month,day\n"); scanf("%d,%d,%d", &year, &month, &day); sum = 0; switch(month) { case 12: sum += 30; case 11: sum += 31; case 10: sum += 30; case 9: sum += 31; case 8: sum += 31; case 7: sum += 30; case 6: sum += 31; case 5: sum += 30; case 4: sum += 31; case 3: sum += 28; if (year % 400 == 0 || (year % 4 == 0 && year % 100 != 0)) sum++; case 2: sum += 31; case 1: sum += day; break; default: printf("data error\n"); } printf("it is the %dth day.\n", sum); }