开发环境为Dev C++
思路:
1、先定义好年、月
2、判断年份是否为闰年
3、不同月份的天数为多少
代码如下:
#include<stdio.h>
int main(void)
{int year,month;printf("input year:");scanf("%d",&year);printf("input month:");scanf("%d",&month);switch(month){case 1:case 3:case 5:case 7:case 8:case 10:case 12:{printf("The number of days in the month is 31 days.");break;}case 4:case 6:case 9:case 11:{printf("The number of days in the month is 30 days.");break;}case 2:if(year%4==0&&year%100!=0||year%400==0) //判断是否为闰年printf("The number of days in the month is 29 days.");elseprintf("The number of days in the month is 28 days.");default:printf("Not this month"); }return 0;
}
本文链接:https://my.lmcjl.com/post/4557.html
展开阅读全文
4 评论