#include<stdio.h>
#define months 12
int main()
{
int days[2][months] = {{31,28,31,30,31,30,31,31,30,31,30,31},
{31,29,31,30,31,30,31,31,30,31,30,31}};
int year, month;
do{
printf("Input year,month:");
scanf("%d,%d", &year, &month);
} while(month < 1 || month > 12); //处理不合法数据的输入
if(((year%4 == 0) && (year%100 != 0))||(year%400 == 0))
printf("The number of days is %d\n",days[1][month-1]); //闰年
else
printf("The number of days is%d\n",days[0][month-1]); //非闰年
return 0;
}
编程实现显示用户输入的月份(考虑闰年)拥有的天数
猜你喜欢
转载自blog.csdn.net/qq_44041942/article/details/85215547
今日推荐
周排行