代码:

// File name:           Multi_select_Switch
// Last modified Date:  2021年10月29日10点42分
// Last Version:        V1.0
// Descriptions:        使用switch语句实现多选#include <iostream>
using namespace std;void showmenu(); // function prototypes
void report();
void comfort();int main()
{char choice;showmenu();cin >> choice;while (choice != 'Q' && choice != 'q'){switch (choice){case 'a':case 'A': cout << "\a\n";break;case 'r':case 'R': report();break;case 'l':case 'L': cout << "The boss was in all day.\n";break;case 'c':case 'C': comfort();break;default: cout << "That's not a choice.\n";}showmenu();cin >> choice;}return 0;
}void showmenu()
{cout << "Please enter A(OR a), R(OR r), L(OR l), C(OR c), or Q(OR q):\n""A(OR a)) o newline R(OR r) report\n""L(OR l) a notice C(OR c) comfort\n""Q(OR q) quit\n";
}
void report()
{cout << "It's been an excellent week for business.\n""Sales are up 120%. Expenses are down 35%.\n";
}
void comfort()
{cout << "Your employees think you are the finest CEO\n""in the industry. The board of directors think\n""you are the finest CEO in the industry.\n";
}

运行结果:

Please enter A(OR a), R(OR r), L(OR l), C(OR c), or Q(OR q):
A(OR a)) o newline R(OR r) report
L(OR l) a notice C(OR c) comfort
Q(OR q) quit
aPlease enter A(OR a), R(OR r), L(OR l), C(OR c), or Q(OR q):
A(OR a)) o newline R(OR r) report
L(OR l) a notice C(OR c) comfort
Q(OR q) quit
APlease enter A(OR a), R(OR r), L(OR l), C(OR c), or Q(OR q):
A(OR a)) o newline R(OR r) report
L(OR l) a notice C(OR c) comfort
Q(OR q) quit
R
It's been an excellent week for business.
Sales are up 120%. Expenses are down 35%.
Please enter A(OR a), R(OR r), L(OR l), C(OR c), or Q(OR q):
A(OR a)) o newline R(OR r) report
L(OR l) a notice C(OR c) comfort
Q(OR q) quit
r
It's been an excellent week for business.
Sales are up 120%. Expenses are down 35%.
Please enter A(OR a), R(OR r), L(OR l), C(OR c), or Q(OR q):
A(OR a)) o newline R(OR r) report
L(OR l) a notice C(OR c) comfort
Q(OR q) quit
l
The boss was in all day.
Please enter A(OR a), R(OR r), L(OR l), C(OR c), or Q(OR q):
A(OR a)) o newline R(OR r) report
L(OR l) a notice C(OR c) comfort
Q(OR q) quit
L
The boss was in all day.
Please enter A(OR a), R(OR r), L(OR l), C(OR c), or Q(OR q):
A(OR a)) o newline R(OR r) report
L(OR l) a notice C(OR c) comfort
Q(OR q) quit
C
Your employees think you are the finest CEO
in the industry. The board of directors think
you are the finest CEO in the industry.
Please enter A(OR a), R(OR r), L(OR l), C(OR c), or Q(OR q):
A(OR a)) o newline R(OR r) report
L(OR l) a notice C(OR c) comfort
Q(OR q) quit
c
Your employees think you are the finest CEO
in the industry. The board of directors think
you are the finest CEO in the industry.
Please enter A(OR a), R(OR r), L(OR l), C(OR c), or Q(OR q):
A(OR a)) o newline R(OR r) report
L(OR l) a notice C(OR c) comfort
Q(OR q) quit
QD:\Prj\C++\C++_Learning\Multi_select_Switch\Debug\Multi_select_Switch.exe (进程 760)已退出,代码为 0。
要在调试停止时自动关闭控制台,请启用“工具”->“选项”->“调试”->“调试停止时自动关闭控制台”。
按任意键关闭此窗口. . .

使用switch实现多选相关推荐

  1. flutter 开关Switch与复选框Checkbox

    Flutter 移动跨平台开发技术分享 目前在西瓜视频上免费刊登 Flutter 系列教程,每日更新,欢迎关注接收提醒 [x1]点击查看提示 [x2]各种系列的教程 [x3]Flutter文章积累目录 ...

  2. 语句:分支语句、switch case ——7月22日

    语句的类型包括:声明语句.表达式语句.选择语句.循环语句.跳转语句.异常语句 1.声明语句引:入新的变量或常量. 变量声明可以选择为变量赋值. 在常量声明中必须赋值. 例如: int i = 0;// ...

  3. c语言蜂鸣警报加循环,如何在此单片机程序基础上加入蜂鸣器报警啊

    /************************************************************************************** *           ...

  4. 红外线接受程序 理解

    1 /************************************************************************************** 2 * 红外通信实验 ...

  5. 寻路机器人单片机程序示例_单片机精华程序代码示例:DS1302时钟程序

    真正的熟练掌握单片机,实际操作是很重要的.多看程序,多分析,从别人规范的程序代码中学习技巧是很必要的. 硬件部分: 程序部分: main.c文件 /************************** ...

  6. 2440 8字数码管 显示0到10 c语言,51单片机对8位数码管依次显示0-7的设计

    共阳极数组0~9:display[]={0xC0,0xF9,0xA4,0xB0,0x91,0xA2,0x82,0xF8,0x80,0x90} 共阳极数组A~F:display[]={0x88,0x83 ...

  7. Mybatis3(3)动态 SQL

    可以利用动态SQL摆脱凭借SQL语句的痛苦. MyBatis 3 大大精简了元素种类,现在只需学习原来一半的元素便可.MyBatis 采用功能强大的基于 OGNL 的表达式来淘汰其它大部分元素. if ...

  8. Flutter 项目开发指导 从基础入门到精通使用目录

    Flutter 从入门 到精通系列文章 本文章为 Flutter 开发中的经验积累分享.教程分享.开发笔记分享目录,持续维护中. 题记 -- 执剑天涯,从你的点滴积累开始,所及之处,必精益求精. Fl ...

  9. 让51单片机八段数码管亮起来(静态显示和动态显示、共阴极和共阳极、位码和段码)

    51单片机数码管的显示 一.八段数码管基础部分 1.八段数码管的共阴极和共阳极 2.八段数码管的位码和段码 二.八段数码管动态显示 1.八个八段数码管动态扫描0到7流水显示 2.八个八段数码管动态扫描 ...

最新文章

  1. linux C++打包程序总结
  2. Python中非常有用的三个数据科学库
  3. 三个Javascript内容切换效果类
  4. swoole mysql 并发_Swoole4 如何打造高并发的PHP7协程Mysql连接池?
  5. volatile和final
  6. 机器学习(七)——规则化和模型选择
  7. el表达式遍历list中的list_EL表达式获取map和list集合中的值 | 学步园
  8. 7-42 行编辑器 (10 分)
  9. 敏捷开发用户故事系列之八:验收标准
  10. SpringBoot @Value 读取配置,太强大了!
  11. 编译好的编译ffmpeg又出错:更改输出目录产生各种古怪错误
  12. maya中英文对照_求玛雅的全部中英文对照
  13. 前端框架light7的使用体验
  14. Cocos2d-x 3.0final 终结者系列教程01-无论是从cocos2d-x2.x升级到版本cocos2d-x3.x
  15. 喜闻项立刚大作:《不给免费WAP以机会》
  16. 【LeetCode】163.Missing Ranges(Medium)(带锁题)解题报告
  17. 群晖从windows迁移到esxi+直通踩坑历险记
  18. asp.net错误解决:Unable to Validate Data in ASP.NET website
  19. 数据库表内导入txt
  20. Day8 打卡第八天

热门文章

  1. (Incomplete) Codeforces #395 (Div 1 + Div 2)
  2. linux 下安装ftp服务器
  3. W3c 中文 文档,很不错
  4. overflow encountered in ubyte_scalars像素加减运算溢出异常
  5. CCF201803-2 碰撞的小球
  6. CCF202109-1 数组推导
  7. C语言课后习题(7)
  8. DirectX_11_游戏编程入门_1
  9. android widget 发送广播,android-从应用程序向小部件发送数据
  10. linux中如何自定义命令行,linux终端颜色和命令行自定义