现有JavaScript程序[br][/br]var x=prompt(“请输入1-5的数字!”,“”);[br][/br]switch (x){[br][/br]case “1”:alert(“one”);break[br][/br]case “2”:alert(“two”);break case “3”:alert(“three”);break case “4”:alert(“four”);break case “5”:alert(“five”);break default: alert(“none”); }[br][/br]运行以上程序,在提示对话框中输入“4”,弹出的对话框将输出: ( )
A: fou
B: four,five,none
C: five
D: five,none
A: fou
B: four,five,none
C: five
D: five,none
举一反三
- 以下JavaScript程序[br][/br] var x=prompt(“请输入1-5的数字!”,“”);[br][/br] switch (x) case “1”:alert(“one”);[br][/br] case “2”:alert(“two”); case “3”:alert(“three”); case “4”:alert(“four”); case “5”:alert(“five”);[br][/br] default:alert(“none”);[br][/br]运行以上程序,在提示对话框中输入“4”,依次弹出的对话框将输出: ( )。 A: four,none B: four,five,none C: five D: five,none
- 分析以下JavaScript程序var x=prompt(“请输入1-5的数字!”,“”);switch (x)case “1”:alert(“one”);case “2”:alert(“two”);case “3”:alert(“three”);case “4”:alert(“four”);case “5”:alert(“five”);default:alert(“none”);运行以上程序,在提示对话框中输入“4”,依次弹出的对话框将输出: A: four,none B: four,five,none C: five D: five,none
- 若a和b均是整型变量,以下正确的switch语句是【】 A: switch (a/b) <br/>{ case 1: case 3.2: y=a+b; break ;<br/>case 0: case 5: y=a-b;<br/>} B: switch (a*a+b*b); <br/>{case 3:<br/>case 1: y=a+b; break ;<br/>case 0: y=b-a; break; } C: switch a <br/>{default : x=a+b;<br/>case 10 : y=a-b;break;<br/>case 11 : y=a*d; break;} D: switch(a+b)<br/>{case 10: x=a+b; break;<br/>case 11: y=a-b; break;<br/>}
- 若a和b均是整型变量,正确的switch语句是( )。 A: switch(pow(a,2)+pow(b,2)); (注:调用求幂的数学函数) <br/>{ <br/>case 1 : case 3 : y=a+b;break; <br/>case 0 : case 5 : y=a-b; <br/>} B: switch(a*a+b*b) <br/>{ <br/>case 3 : <br/>case 1 : y=a+b; break; <br/>case 0 : y=b-a; break; <br/>} C: switch a <br/>{ <br/>default :x=a+b; <br/>case 10 : y=a-b; break; <br/>case 11 : x=a*d; break; <br/>} D: switch(a+b) <br/>{ <br/>case10 : x=a+b; break; <br/>case11 : y=a-b; break; <br/>}
- The switch statement with different functions from the statement if (a == 1) a = b; else a ++; is ( ). A: switch(a) { case 1:a=b;break; <br/>default : a++; <br/>} B: switch(a==1) { case 0:a=b;break;<br/>case 1: a++;<br/>} C: switch(a) { default:a++;break; <br/>case 1:a=b; <br/>} D: switch(a) { default:a++;break; <br/>case 1:a=b; <br/>}