一个小问题,一条语句的位置问题。
#include <stdio.h>void main()
{int x,y,z,n,i;
printf("please enter year,month,day:");
scanf("%d.%d.%d",&x,&y,&z);
n=(y-1)*30+z+i; /*<1>*/
switch(y)
{ case 1:
case 2:
case 3: i=0;break;
case 4:
case 5: i=1;break;
case 6:
case 7: i=2;break;
case 8: i=3;break;
case 9:
case 10:
case 11:
case 12: i=4;break;
}
n=(y-1)*30+z+i; /*<2>/
if((x%4==0&&x%100!=0)||x%400==0)
{ n--;
printf("This year is a leap year,");
}
else printf("This year is not is leap year,");
n=(y-1)*30+z+i; /*<3>*/
printf("Thday is the %drd day this year\n",n);
}
程序中有三处用 n=(y-1)*30+z+i;,请问放哪是对的,为什么?