【switch语句结构】写出switch语句的语法结构switch语句的语法结构,_英语_vdgvgfng00F72
编辑: admin 2017-15-06
-
4
swith([char||int]){
case states : do what?;[break;]
case states : do what?;[break;]
default :do what?;
}
例:
int i= 0;
switch(i){
case 1:System.out.println(1);break;
case 2:System.out.println(2);break;
default :System.out.println("default");
}
互助这道作业题的同学还参与了下面的作业题
题1: 写出switch分支结构的语法结构,并写出其执行过程
switch(A)
{
case 3:
break
case 5:
break
case 6:
break
}
A的数据类型只能为int,short,char等数据.
其未被编译器优化时,其真正执行过程基本等同与if 与else if
上面的程序可以写为
if(A == 3)
{
}
else if(A==5)
{
}
else if(A==6)
{
}
上面是每个case分支都有break的情况下,如果某个分支没有break时,将一直执行到某个break时整个swith才结束,当然有可能后面一直都没有break,那天他就执行到最后.
题2: 【写了个句子whatcanweknowfromthepictureisthataoldmanfelldown,ignoredbypeoplepassedhimexceptforDinnawhosavehimoutofdanger】
what can we know from the picture is that a old man fell down ,ignored by people passing him
except for Dinna who saved him out of danger.
有两个小问题一个是应该用现在分词表示进行passing, 另一个是应该用过去时saved.
题3: switch-case结构的语法格式.
int caseSwitch = 1;
switch (caseSwitch)
{
case 1:
Console.WriteLine("Case 1");
break;
case 2:
Console.WriteLine("Case 2");
break;
default:
Console.WriteLine("Default case");
break;
}
题4: 【这句话写的挺别扭的,语法和结构都有问题吧?请问怎么改?thedifferentjobswasengagedthatsuitablefordifferenttogender,翻译:不同性质的工作适合不同性别的个体去从事.】[英语科目]
Jobs of different nature are suitable for people of different genders to get engaged in.
专业8级翻译
题5: 分析下面句子的语法结构/语法成分Weshouldnotoverlookthefactthatthepositivesidethat/whichthatstudentsstudyingroupshasisofgreatusetotheirfuturelife[英语科目]
We should not overlook the fact 这是主句
that the positive side that / which that students study in groups has is of great use to their future life是fact的名词性从句,指代fact的内容
that / which that students study in groups has is of great use to their future life是定语从句,先行词是the positive side