第1个回答 推荐于2016-03-20
#include<stdio.h>
void main()
{
int nian,yue,ri,leap,sum;
printf("\n 请输入年月日: \n");
scanf("%d%d%d",&nian,&yue,&ri);
switch(yue)
{
case 1:sum=0;
break;
case 2:sum=31;
break;
case 3:sum=59;
break;
case 4:sum=90;
break;
case 5:sum=120;
break;
case 6:sum=151;
break;
case 7:sum=181;
break;
case 8:sum=212;
break;
case 9:sum=243;
break;
case 10:sum=273;
break;
case 11:sum=304;
break;
case 12:sum=334;
break;
default:
printf("\n 数据错误 \n");
}
sum=sum+ri;
if((nian%400==0) ||(nian%4==0 && nian%100!=0 ))
leap=1;
else
leap=0;
if(leap==1 && nian>3)
sum++;
printf("\n 这一天是这一年的第 %d 天 \n",sum);
}本回答被提问者采纳
第2个回答 2008-04-28
#include "stdio.h"
struct
{int year;
int month;
int day;
}date;
void main()
{int i,days;
int _tab[0,31,28,31,30,31,30,31,31,30,31,30,31};
printf("input year,month,day:");
scanf("%d,%d,%d",&date.year,&date.month,&date.day);
days=0;
for(i=1;i<date.month;i++)
days=days+da_tab[i];
days=days+date.day;
if((date.year%4==0&&date.year%100==0||date.year%400==0)&&date.month>=3)
days+=1
printf("%d/%d is the %dth day in %d.\n"date.month,date.day,days,date.year);
}