题目:输入年月日,求其是该年的第几天
void datesum(int year,int month,int date)
{
int i,j,sum,k=0;
int mon[12];
int mon2[2][12]=
{
{31,29,31,30,31,30,31,31,30,31,30,31},
{31,28,31,30,31,30,31,31,30,31,30,31}
}
if((year%4==0&&year%100!=0)||year%400==0)
for(i=1;i<=12;i++) mon[i]=mon2[0][i];
else
for(i=1;i<=12;i++) mon[i]=mon2[1][i];
for(i=1;i<=month;i++)
{k=k+mon[i];}
sum=k+date;
printf("di %d tian",sum);
}
main()
{
int year,month,date;
scanf("%d%d%d",&year,&month,&date);
if(month>12||month<1||date>31||date<1)
printf("input error!\n");
datesum(year,month,date);
getch();
}
我找不出为什么错了......
[此贴子已经被作者于2007-6-29 11:31:46编辑过]