请写出与以下else-if语句等价的switch语句。 if(choice == 1) price = 3.0; else if(choice == 2) price = 2.5; else if(choice == 3) price = 4.0; else if(choice == 4) price = 3.5; else{ price = 0.0; } switch { case 1: price=3.0; break; case 2: price=2.5; break; case 3:price=4.0;break; case 4: price=3.5;break; price=0.0; break; }
请写出与以下else-if语句等价的switch语句。 if(choice == 1) price = 3.0; else if(choice == 2) price = 2.5; else if(choice == 3) price = 4.0; else if(choice == 4) price = 3.5; else{ price = 0.0; } switch { case 1: price=3.0; break; case 2: price=2.5; break; case 3:price=4.0;break; case 4: price=3.5;break; price=0.0; break; }
switch语句相当于一系列的else-if语句,也可以实现多分支结构。
switch语句相当于一系列的else-if语句,也可以实现多分支结构。
else-if多路结构可看成是每个____后面,又嵌套了一个if-else结构。</p></p> ______
else-if多路结构可看成是每个____后面,又嵌套了一个if-else结构。</p></p> ______
__would like to go to the park with me? A: Whom else B: What else C: Who else D: Else who
__would like to go to the park with me? A: Whom else B: What else C: Who else D: Else who
This pen is not mine, it must be ____. A: somebody else's B: somebody else' C: somebody's else D: somebody' else
This pen is not mine, it must be ____. A: somebody else's B: somebody else' C: somebody's else D: somebody' else
If that pen is not hers, ____________ can it be? A: who else B: whose else's C: who else's D: who's else
If that pen is not hers, ____________ can it be? A: who else B: whose else's C: who else's D: who's else
C语言中要实现多分支结构,除了用else-if语句和嵌套的if语句实现外,还可以用实现。
C语言中要实现多分支结构,除了用else-if语句和嵌套的if语句实现外,还可以用实现。
6. Do you have _________ to tell me? A. something else B. else something C. else anything D. anything else
6. Do you have _________ to tell me? A. something else B. else something C. else anything D. anything else
-Whose umbrella is it?-It's ________. A: somebody else's B: Somebody else C: Somebody's else's D: Somebody's else
-Whose umbrella is it?-It's ________. A: somebody else's B: Somebody else C: Somebody's else's D: Somebody's else
I want to know ____ I can do for you. A: how else B: what else C: when else D: where else
I want to know ____ I can do for you. A: how else B: what else C: when else D: where else