以下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
A: four,none
B: four,five,none
C: five
D: five,none
举一反三
- 现有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
- 分析以下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
- ,y=5;[br][/br] switch(x) [br][/br]{ case 1: x++;[br][/br] default:x+=y;[br][/br] case 2:y--;[br][/br] case 3:x--; }[br][/br]printf(“x=%d,y=%d”,x,y);[br][/br]} A: x=15,y=5 B: x=10,y=5 C: x=14,y=4 D: x=15,y=4
- 若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/>}
- 下面程序的输出结果是[br][/br] iX=3[br][/br] iX>3[br][/br]____ 。[br][/br]#include "stdio.h"[br][/br]main()[br][/br]{int iX=3;[br][/br] switch(iX)[br][/br] { case 1:[br][/br] case 2: printf("iX[3\n");<br] case 3: printf("iX=3\n");[br][/br] case 4:[br][/br] case 5: printf("iX>3\n");[br][/br] default: printf("iX unknow\n");[br][/br] }[br][/br]}