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<month;i++)
day+=days;
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);
}希望能明白!经过测试的!
|