马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
#include<stdio.h>
void main()
{
int y, n, s = 0;//定义变量
scanf_s("%d-%d", &y, &n);//输入年月
switch (n)//根据月份判断天数
{
case 1:s = 31; break;
case 2:s = 28; break;
case 3:s = 31; break;
case 4:s = 30; break;
case 5:s = 31; break;
case 6:s = 30; break;
case 7:s = 31; break;
case 8:s = 31; break;
case 9:s = 30; break;
case 10:s = 31; break;
case 11:s = 30; break;
case 12:s = 31; break;
}
if (n == 2)//判断闰年2月差异
{
if (y % 4 == 0 && y % 100 != 0 || y % 400 == 0)
s = 29;
else
s = 28;
}
printf("%d\n", s);
}
|