切换语句 [英] The Switch Statement

查看:101
本文介绍了切换语句的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好...
我想要一些关于如何在显示写选择菜单时编写switch语句的反馈,例如C代表支票,D代表存款,W代表提款,Q代表退出.允许用户使用大写和小写字母.
我相信它是:
案例``D''
情况"d"
例如对吧?
然后程序要求用户输入:如果用户选择"D",然后要求用户输入存款金额,然后添加帐户余额.
无论如何,我们将不胜感激.
我确实在另一篇文章中写了出来,但没有人回答,我想C ++吓到了人们,嘿嘿.
[消除了对表情符号的过度使用]

Hello...
I would like some feedback on how to write a switch statement on displaying a menu on writing choices, like C for check, D for Deposit, W for withdrawl, and Q for Quit. Allow user to use upper and lower cases.
I believe it''s :
case ''D''
case ''d''
for example right?
Then the program asks user to input: if user selects ''D'' then ask user to enter the amount of deposit, then add account balance.
Anyway, any help is appreciated.
I did write it out in another post but no-one replied, I think C++ scares folks, hey me to.
[Removed irritatingly excessive use of smilies]

推荐答案

是的,是这样的,除了表示形式中的句法错误
Yes, that''s how it is done, except for the syntactical error in your representation
case ''d'':
case ''D'':
//your code here
break;



这里有示例:
http://www.cplusplus.com/doc/tutorial/control/ [ http://msdn.microsoft.com/en-us/library/k0t5wee3(VS .80).aspx [ ^ ]



There are examples here:
http://www.cplusplus.com/doc/tutorial/control/[^]
http://msdn.microsoft.com/en-us/library/k0t5wee3(VS.80).aspx[^]


这篇关于切换语句的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆