菜单类型的重复选择,使用while做到能够一直选择
2014-03-21 16:01
246 查看
实例:
#include <iostream> using namespace std; void showMenu(); int main() { char ch; showMenu(); cin >> ch; while(ch != 'q') { if(ch != 'c' && ch != 'p' && ch != 't' && ch != 'g') { cout << "Please enter a c, p, t, or g: "; cin >> ch; } switch(ch) { case 'c': cout << "ccccc\n"; break; case 'p': cout << "I am a pianist.\n"; break; case 't': cout << "A maple is a tree.\n"; break; case 'g': cout << "This is a game.\n"; break; } showMenu(); cin >> ch; } cout << "Bye!\n"; return 0; } void showMenu() { cout << "Please enter one of following chocies:" << endl; cout << "c) carnivore p) pianist\n" << "t) tree g) game\n" << "q) quit"; cout << "Please enter a c, p, t, or g: "; }
相关文章推荐
- 使用template扩展已有的DDX_Text函数,使扩展能够同时支持各种数据类型的一个例子
- 使用DOS命令实现选择菜单
- 使用template扩展已有的DDX_Text函数,使扩展能够同时支持各种数据类型的一个例子
- MariaDB(MySQL)创建、删除、选择及数据类型使用详解
- 多文档,新建多种文件类型(不使用文件类型选择框)
- 过滤器的使用,这个方法可以在选择对象时候过滤到其他的只选自己想要的类型。
- iOS之UITextView的使用——自定义选择文本后的菜单
- Js 日期选择,可以的一个页面中重复使用本JS日历,兼容IE及火狐等主流浏览器,而且界面简洁、美观,操作体验也不错。
- 使用Ext Js3.2实现的具有选择框的菜单,使用Ext.menu.Menu来实现
- 不要重复DAO!使用Hibernate 和Spring AOP 构建泛型类型安全的DAO
- 复习 使用for、while循环遍历文件,数据类型转换
- 多线程编程之重点--使用DSP/BIOS时选择线程类型的参考方法
- 零元学Expression Blend 4 - Chapter 35 讨厌!!我不想一直重复设定!!『Template Binding』使用前後的差异
- 右键菜单的“打开方式―选择程序”功能不能使用
- 设置右键菜单可以选择使用qtcreator打开
- 设置右键菜单可以选择使用qtcreator打开
- C语言中数据类型的使用选择
- ionic2 使用slides制作滑动效果的类型选择栏
- 复习 使用for、while循环遍历文件,数据类型转换
- SQLite使用&&选择表类型