输入年份和月份,判断是否闰年季度及天数
1个回答
展开全部
intjudgeyear(int year)
{
if(0==year%400||(0==year%4&&year%100!=0)return 1; //不太记得C里面取余是%、\还是/
return 0;
}
void main()
{
int year=0,month=0,day=0,i=0,date=0;
printf("请输入年:\n");
scanf("%d",&year);
printf("请输入月:\n");
scanf("%d",&month);
printf("请输入日:\n");
scanf("%d",&day);
for(i=1;i<month;i++)
{
switch(i)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:date+=31;break;
case 4:
case 6:
case 9:
case 11:date+=30;break;
case 2:
1==judgeyear(year)?
date+=29:
date+=28;
break;
}
}
printf("指定的日期是当年的第%d天。",date);
return;
}
{
if(0==year%400||(0==year%4&&year%100!=0)return 1; //不太记得C里面取余是%、\还是/
return 0;
}
void main()
{
int year=0,month=0,day=0,i=0,date=0;
printf("请输入年:\n");
scanf("%d",&year);
printf("请输入月:\n");
scanf("%d",&month);
printf("请输入日:\n");
scanf("%d",&day);
for(i=1;i<month;i++)
{
switch(i)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:date+=31;break;
case 4:
case 6:
case 9:
case 11:date+=30;break;
case 2:
1==judgeyear(year)?
date+=29:
date+=28;
break;
}
}
printf("指定的日期是当年的第%d天。",date);
return;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询