C语言添加一句判断是否闰年的语句 输出某年某月的天数
#include<stdio.h>voidmain(){intyear,month,days;printf("pleaseenteryearandmonth:\n");s...
#include<stdio.h>
void main ()
{
int year,month,days;
printf("please enter year and month:\n");
scanf("%d,%d",&year,&month);
switch(month)
{case 2:
-----------------------------------------------------------
days=29;
else
days=28;
break;
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:days=31;
case 4:
case 6:
case 9:
case 11:days=30;
printf("days=%d",days);
}
在线求解啊 各位高手 菜鸟
在线等 展开
void main ()
{
int year,month,days;
printf("please enter year and month:\n");
scanf("%d,%d",&year,&month);
switch(month)
{case 2:
-----------------------------------------------------------
days=29;
else
days=28;
break;
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:days=31;
case 4:
case 6:
case 9:
case 11:days=30;
printf("days=%d",days);
}
在线求解啊 各位高手 菜鸟
在线等 展开
展开全部
判断闰年的语句:if((year%4==0&&year%100!=0)||(yaer%400=0))
leap=1;
else leap=0;
leap=1表示是闰年,=0表示不是闰年。
leap=1;
else leap=0;
leap=1表示是闰年,=0表示不是闰年。
更多追问追答
追问
能帮我把这个程序做完吗?那个判断完了怎么连接?谢谢大侠啊
追答
#include
void main ()
{
int year,month,days,leap=0;
printf("please enter year and month:\n");
scanf("%d,%d",&year,&month);
if((year%4==0&&year%100!=0)||(yaer%400=0))
leap=1;
switch(month)
{case 2:
if(leap==1) days=29;
else
days=28;
break;
case 1:days=30;break;
case 3:days=30;break;
case 5:days=30;break;
case 7:days=31;break;
case 8:days=31;break;
case 10:days=31;break;
case 12:days=31;break;
case 4:days=31;break;
case 6:days=31;break;
case 9:days=30;break;
case 11:days=30;
printf("days=%d",days);
}
你运行试一下,不行再问我。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询