#include"stdio.h"
int main()
{
int a,i=0,yearday;
struct
{
int year;
int month;
int day;
}date1;
static int month[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 input the year month and day:\n");
scanf("%d,%d,%d",&date1.year,&date1.month,&date1.day);
scanf("%d",&date1.day);
a=date1.month;
yearday=date1.day;
if((date1.year%4==0&&date1.year%100!=0)||(date1.year%400==0))
{
for(i=0;i<a;i++)
yearday+=month[0][i];
}
else
{
for(i=0;i<a;i++)
yearday+=month[1][i];
}
printf("the yearday is %d\n",yearday);
}
[此贴子已经被作者于2007-8-27 16:04:06编辑过]