问题:
解答:
#include <iostream>
using namespace std;void showMenu()
{cout << "请选择一个选项(单选题):" << endl;cout << "a) 10\t\tb) 20" << endl;cout << "c) 30\t\td) 40" << endl;
}int main()
{char choose;do{showMenu();cin >> choose;switch (choose){case 'a':cout << "幼学之年" << endl;break;case 'b':cout << "弱冠之年" << endl;break;case 'c':cout << "而立之年" << endl;break;case 'd':cout << "不惑之年" << endl;break;}} while (choose != 'a' && choose != 'b' && choose != 'c' && choose != 'd');return 0;
}
运行结果:
考查点:
- 循环
- switch
2024年8月28日19:24:36