Copyright (c) 2016,
All rights reserced.
文件名称:main.cp
作者 :孙亚茹
完成日期:2016.3.15
问题描述:输入年份和月份,输出本月有几天,何理选择分支语句。
#include <iostream>
using namespace std;
int main()
{
int year,mouth;
cin>>year>>mouth;
switch(mouth)
{
case 2:
{
if((year%4==0&&year%100!=0)||year%400==0)
mouth=29;
else
mouth=28;
}
break;
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
mouth=31;
break;
default :
mouth=30;
}
cout<<mouth;
return 0;
}