{
int a[12]={31,28,31,30,31,30,31,31,30,31,30,31};//建立数组,一年每个月的日子数(平年)
if((year%400==0)||(year%4==0&&year%100!=0)) a[1]++;//如果为闰年,2月份加一天
if(day>a[mouth-1]||day<1)//判断天数是否合法
return true;
else
return false;
}
void main()//根据年月日返回该天在一年的哪一天
{
int i,year,mouth,day;
int sum,sign;
int a[12]={31,28,31,30,31,30,31,31,30,31,30,31};
do
{
sum=0;sign=0;
puts("请输入年、月、日:");
scanf("%d%d%d",&year,&mouth,&day);
if(((year%400==0)||(year%4==0&&year%100!=0))&&mouth>2)
{
sum=day+1;//闰年,记得加1
}
else sum=day;
for(i=0;i
if(year<1||mouth<1||mouth>12||isday(day,mouth,year))//判断日期是否合法
{
puts("输入错误,请重新输入:");
sign=1;
}
}while(sign);
printf("为第%d天\n",sum);
}