参考答案和解析
正确答案:

 

:( ( a + b ) + abs( a - b ) ) / 2

更多“There are two int variables: a and b, don’t use“if”, “? :”, “switch”or other judgement ”相关问题
  • 第1题:

    针对下列程序段,需要( )个测试用例才可以满足语句覆盖的要求。
    switch(value){case 0:other=30;break;case 1:other=50;break;case 2:other=300;case 3:other=other/value;break;default:other=other*value;}

    A.2
    B.3
    C.4
    D.5

    答案:C
    解析:
    本题考查白盒测试用例设计方法--语句覆盖法的概念。语句覆盖(Statement Coverage)的含义是:选择足够多的测试数据,使被测程序中的每条语句至少执行一次。

  • 第2题:

    写出程序的输出: int i=1; switch (i%3 ) { case 0: printf("zero"); case 1: printf("one"); case 2: printf("two"); }


    onetwo

  • 第3题:

    在switch语句中,switch后面括号内的表达式的类型不能是____。

    A.double

    B.long

    C.char

    D.int


    int;byte;char

  • 第4题:

    在switch语句中,switch后面括号内的表达式的类型不能是()

    A.byte

    B.long

    C.char

    D.int


    错误

  • 第5题:

    1、针对下列程序段,需要()个测试用例才可以满足语句覆盖的要求。 switch (value ) { case 0: other = 30; break; case 1: other = 50; break; case 2: other = 300; case 3: other = other/value; break; default: other = other * value; }

    A.2

    B.3

    C.4

    D.5


    4