切换语句中的多个表达式 [英] Multiple Expressions in Switch Statements
本文介绍了切换语句中的多个表达式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在C ++中,我的切换是当我要求它评估一个表达式时,声明是可以的。 (我正在评估的数字是十个单位数之一;我有10个数字的10个案例。)
但是,我有五个单独的数字要评估。 />
我不能相信唯一的解决办法就是:
In C++, my "switch" statement is okay when I ask it do evaluate ONE expression. (My number that I''m evaluating is one of ten single digits; I have ten cases for the ten digits.)
BUT, I have five separate digits to evaluate.
I can''t believe that the only solution is to do:
展开 | 选择 | 换行 | 行号
推荐答案
不确定您的逻辑要求?
是与案例0相关的陈述:案例1:在所有switch语句中都是相同的。类似
not sure about your logic requirements?
are the statements associated with case 0:. case 1: etc the same in all the switch statements. Something like
展开 | 选择 | Wrap | 行号
我有一个包含五个不同数字(数字)的列表。
我的switch语句执行的操作不同,无论是数字== 1还是数字== 2等等。
我正在执行switch语句五次不同的时间到五个不同的数字。
我不喜欢这样做:
I have a list of five different numbers (digits).
My switch statement does something different whether the digit == 1 or whether the digit == 2, etc.
I''m doing the switch statement five different times to five different digits.
It''s not liking me trying this:
展开 | 选择 | Wrap | 行号
将五位数存储在数组中并使用循环
you store the five digits in an array and use a loop
展开 | 选择 | Wrap | 行号
这篇关于切换语句中的多个表达式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文