采用switch 语句
代码如下
#include<iostream>
using namespace std;
int main()
{
int month;
cin >> month;
switch ((month-1)/3+1)
{
case 1:cout <<month << "月是第一季度" << endl; break;
case 2:cout << month << "月是第二季度" << endl; break;
case 3:cout << month << "月是第三季度" << endl; break;
case 4:cout << month << "月是第四季度" << endl; break;
defacult: cout << "输入错误" << endl; break;
}
return 0;
}