#include<stdio.h>
int main()
{
int year,month,days,day
printf("请输入年月日")
scanf("%d-%d-%d"袜指,&year,&month,&days)
switch(month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12: day=31break
case 4:
case 6:
case 9:
case 11:day=30break
case 2:
if(year%4==0&&year%100!=0||year%400==0)
day=29
else
day=28break
default :printf("error\n")
}
printf("拆亮这个月有告御配%d天",day)
}
主要手漏判断出该年是否为闰年即可,C语言代码如下:
#include <stdio.h>
int main(){
int y, m
scanf("%d %d", &y, &m)
int month[13] = {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}
if ((y % 4 == 0 &老薯蚂&y % 100 != 0) || (y % 400 == 0)) // 闰年
month[2] = 29// 闰年2月为29天
printf("%d年%d月有%d天\n", y, m, month[m])
侍埋 return 0
}
运行结果如下:
输出符合题意,望采纳~
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)