我用函数编写判断这一天是这一年的第几天不知道哪里出错,大家看看
输入某年某月某日,判断这一天是这一年的第几天?程序代码:
main() { int day,month,year,a; int sum1(int); int sum2(int); printf("Please enter the date, and separated by periods: "); scanf("%d.%d.%d",&day,&month,&year); if(year%10==0&&year%400==0||(year%10!=0&&year%4==0)) a=sum1(month); else a=sum2(month); printf("This day is this year %d\n",a+day); } int sum1(int m) { int a; a=switch(m) { case 1:31;break; case 2:60;break; case 3:91;break; case 4:121;break; case 5:152;break; case 6:182;break; case 7:213;break; case 8:244;break; case 9:274;break; case 10:305;break; case 11:335;break; case 12:366;break; } return(a); } int sum2(int m) { int a; a=switch(m) { case 1:31;break; case 2:60;break; case 3:90;break; case 4:120;break; case 5:151;break; case 6:181;break; case 7:212;break; case 8:243;break; case 9:273;break; case 10:304;break; case 11:334;break; case 12:365;break; } return(a); }
我不知道哪里出错了,请大家看看,谢谢