为什么结果是随机数,给位大神求教
#include <stdio.h>int main()
{
int moth,day,year,n,s=0,i;
printf("请输出年月日:");
scanf("%d%d%d",&year,&n,&i);
moth=n;
do
{
switch(moth)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:day=31; break;
case 4:
case 6:
case 9:
case 11:day=30;break;
}
s+=day;
moth--;
}while(moth>0);
s=s-31;//switch上面没有2,系统默认给了day=31的列式。
if((year%4==0&&year%100!=0)||(year%400==0))//判断年是闰年
s=s+29;
else
s=s+28;
day=s+i;
printf("%d\n",day);
return 0;
}