#include<stdio.h>
void main()
{
int y,m,d,result,le,i,S[2][13];
printf("please imput the day of year:");
scanf("%d%d%d",y,m,d); /*应当是scanf("%d%d%d",&y,&m,&d);*/
S[2][13]={{0,31,28,31,30,31,30,31,31,30,31,30,31},
{0,31,29,31,30,31,30,31,31,30,31,30,31}}; /*数组只能在声明的时候,给所有的元素赋值*/
le=((y%4==0&&y%100!=0)||y%400==0);
for(i=0;i<m;i++)
{
result=d+S[le][i]; /*有问题*/
}
// return re;
printf("result is %d",result);
}
/*稍微改了一些,应当是可以的*/
#include<stdio.h>
void main()
{
int y,m,d,result,le,i,S[2][13]={{0,31,28,31,30,31,30,31,31,30,31,30,31},\
{0,31,29,31,30,31,30,31,31,30,31,30,31}};
printf("please imput the day of year:");
scanf("%d%d%d",&y,&m,&d);
le=((y%4==0&&y%100!=0)||y%400==0);
result=d;
for(i=0;i<m;i++)
{
result+=S[le][i];
}
printf("result is %d",result);
getch();
}