程序代码如下:从键盘输入以下数据:2<回车>7<回车>则程序输出为( )。
A. the output data is 2
B. the output data is 7
C. the output data is 0
D. the output data is 1
查看答案
设变量已正确定义,为了检查以下else-if语句的分支是否正确,至少需要设计( )组测试用例。
A. 7
B. 6
C. 5
D. 4
设变量已正确定义,以下( )与其它switch语句不等价。
A. switch(choice){ case 1: price = 3.0; break; case 2: price = 2.5; break; case 3: price = 4.0; break; case 4: price = 3.5; break; default: price = 0.0; break;}
B. switch(choice){ default: price = 0.0; break; case 4: price = 3.5; break; case 3: price = 4.0; break; case 2: price = 2.5; break; case 1: price = 3.0; break; }
C. switch(choice){ case 1: price = 3.0; break; case 2: price = 2.5; break; case 3: price = 4.0; break; case 4: price = 3.5; break;}
D. price = 0.0; switch(choice){ case 1: price = 3.0; break; case 2: price = 2.5; break; case 3: price = 4.0; break; case 4: price = 3.5; break;}
有一函数y=⎩⎨10−1x>0x=0x<0 ,以下程序段中错误的是()。
A. if(x > 0) y = 1;else if(x == 0) y = 0;else y = -1;
B. y = 0;if(x > 0) y = 1;else if(x < 0) y = -1;
C. y = 0; if(x >= 0); if(x > 0) y = 1; else y = -1;
D. if(x >= 0)if(x > 0) y = 1;else y = 0;else y = -1;