//输入年月日,输出是该年第几天
#include
int sum(int month,int day)
{
int days[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int i;
for(i=1;i
return(day);
}
int leap(year)
{
int leap=0;
if((year%4==0&&year%100!=0)||(year%400==0))
leap=1;
return leap;
}
void main()
{
int year,month,day,num;
printf("Please input year,month,day:\n");
scanf("%d,%d,%d",&year,&month,&day);
num=sum(month,day);
if(leap(year)&&month>=3)
num++;
printf("It is the %dth day.\n",num);
}
//输入年月日,输出是该年第几天
#include
int
sum(int
month,int
day)
{
int
days[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};
int
i;
for(i=1;i
return(day);
}
int
leap(year)
{
int
leap=0;
if((year%4==0&&year%100!=0)||(year%400==0))
leap=1;
return
leap;
}
void
main()
{
int
year,month,day,num;
printf("Please
input
year,month,day:\n");
scanf("%d,%d,%d",&year,&month,&day);
num=sum(month,day);
if(leap(year)&&month>=3)
num++;
printf("It
is
the
%dth
day.\n",num);
}
这个,如果傻一点点可以用个循环从1月1日起来始累加,直到加到等于你的这个日期为止