问题:输入年和月,输出该月对应的天数。
提示:
1,3,5,7,8,10,12: 31天
4,6,9,11: 30天
2: 28,29
分析:
输入一个年份和月份--》year,month
switch(month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:days=31;break;
case 4:
case 6:
case 9:
case 11:days=30;break;
case 2:if ((year%400==0)||(year%4==0&&year%100!=0))
days=29;
else
days=28;
}
输出days的值
上一页
[1]
[2]
[3]
[4]
[5]