解答过程看不懂啊
为什么case1:sum=0????
为什么case1:sum=0????
2018-12-17
#include <stdio.h>
int main()
{
/* 定义需要计算的日期 */
int year = 2008;
int month = 8;
int day = 8;
int i=0,j=0;
if(month>2)
{
if(year%4==0&&year%100!=0||year%400==0)i=1;
else i=0;
}
switch(month)
{
case 1:
j=day;break;
case 2:
j=day+31;break;
case 3:
j= day+31+28;break;
case 4:
j = day+31+30+28;break;
case 5:
j= day+31*2+28+30;break;
case 6:
j = day+31*2+28+30*2;break;
case 7:
j =day+31*3+28+30*2;break;
case 8:
j = day+31*4+28+30*2;break;
case 9:
j = day+31*4+28+30*3;break;
case 10:
j = day+31*5+28+30*3;break;
case 11:
j= day+31*5+28+30*4;break;
case 12:
j= day+31*6+28+30*4;break;
}
printf("%d年%d月%d日是该年的第%d天\n",year,month,day,j+i);
return 0;
}
举报