ex3_05.cpp

来自「Beginning Visual C++ 6源码。Wrox。」· C++ 代码 · 共 37 行

CPP
37
字号
// EX3_05.CPP
// Using the switch statement
#include <iostream>

using namespace std;

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
        << 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 + =
减小字号Ctrl + -
显示快捷键?