list0716.cpp
来自「teach yourself C++ in 21 days 第五版」· C++ 代码 · 共 27 行
CPP
27 行
//Listing 7.16
// Demonstrates switch statement
#include <iostream>
int main()
{
using namespace std;
unsigned short int number;
cout << "Enter a number between 1 and 5: ";
cin >> number;
switch (number)
{
case 0: cout << "Too small, sorry!";
break;
case 5: cout << "Good job!" << endl; // fall through
case 4: cout << "Nice Pick!" << endl; // fall through
case 3: cout << "Excellent!" << endl; // fall through
case 2: cout << "Masterful!" << endl; // fall through
case 1: cout << "Incredible!" << endl;
break;
default: cout << "Too large!" << endl;
break;
}
cout << endl << endl;
return 0;
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?