📄 prog4_08.cpp
字号:
// Example 4.8 Using the switch statement
#include <iostream>
using std::cin;
using std::cout;
using std::endl;
int main() {
int choice = 0; // Store selection value here
cout << endl
<< "Your electronic recipe book is at your service." << endl
<< "You can choose from the following delicious dishes: "
<< endl
<< "1 Boiled eggs" << endl
<< "2 Fried eggs" << endl
<< "3 Scrambled eggs" << endl
<< "4 Coddled eggs" << endl
<< endl << "Enter your selection number: ";
cin >> choice;
switch(choice) {
case 1:
cout << endl << "Boil some eggs." << endl;
break;
case 2:
cout << endl << "Fry some eggs." << endl;
break;
case 3:
cout << endl << "Scramble some eggs." << endl;
break;
case 4:
cout << endl << "Coddle some eggs." << endl;
break;
default:
cout << endl << "You entered a wrong number, try raw eggs." << endl;
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -