今天是第几天简单问题
输入年月日 输出第几天#include<stdio.h>
main()
{
int run(int year);
int year,moth,day, i,a[12],k;
int b,r;
printf("input year ,moth and day");
scanf("%d%d%d",&year,&moth,&day);
k=run(year);
if(k==0) a[12]={1,2,3,4,5,6,7,8,9,10,11,12};
else a[12]={1,1,3,4,5,6,7,8,9,10,11,12};
for(i=0;i<moth;i++)
b+=a[i];
r=b+day;
printf("pass %d days",r);
}
int run(int year) /*是否论年*/
{
if((year%4==0||year%100!=0)&&year%400==0)
k=0;
else k=1;
return(k)
}
运行提示 if(k==0) a[12]={1,2,3,4,5,6,7,8,9,10,11,12};
有错误 什么原因?谢谢