判断某年某月有几天
#include <iostream>
using namespace std;
int main()
{
//判断某年某月有几天
int month;
int year;
cout << "请输入您想判断的年份: " << endl;
cin >> year;
cout << "请输入您想判断的月份: " << endl;
cin >> month;
switch(month)
{
case 1:
case 3:
case 5:
case 7:
case 8:
case 10:
case 12:
cout << "您输入的月份一共有31天!" << endl;
break;
case 4:
case 6:
case 9:
case 11:
cout << "您输入的月份一共有30天!" << endl;
break;
case 2:
year = year % 400;
if(year == 0)
{
cout << "您输入的月份一共有29天!";
break;
}
else
{
cout << "您输入的月份一共有28天!";
break;
}
default:
cout << "您输入的月份不合法!";
break;
}
return 0;
}