● 给定C 语言程序:
int foo( int x, int y, int d)
{
if( x != 0 ) {
if ( y == 0 ) d = d / x;
else d = d / (x * y );
} else {
if( y == 0 ) d = 0;
else d = d / y;
}
return d ;
}
当用路径覆盖法进行测试时,至少需要设计 (31) 个测试用例。
(31)A. 3 B. 4 C. 5 D. 8
第1题:
以下程序执行后的输出结果是 #include<iostream> using namcspace std; void try(int,int,int,int); int main() { int x,y,z,r; x=1; y=2; try(x,y,z,r); cout<<r<<end1; return 0; } void try(int x,int y, int z,int r) { z = x+y; x = x*x; y = y*y; r = z+x+y; }
A.18
B.9
C.10
D.不确定
第2题:
以下程序执行后的输出结果是 #include<iostream>. using namespace std; void try(int,int,int,int); int main() { int x,y,z,r; x=1; y=2; try(x,y,z,r); cout<<r<<end1; return 0; } void try(int x,int y, int z,int r) { z = x+y; x = x*x; y = y*y; r = z+x+y; }
A.18
B.9
C.10
D.不确定
第3题:
10、求y=cos(x)从0到π的积分,正确的命令为_________。
A.int(y,x,0,pi)
B.int(x,0,pi)
C.int(x,y,0,pi)
D.int(0,pi,x,y)
第4题:
以下程序执行后的输出结果是( )。 #include<iostream> using namespace std; void try(int,int,int,int); int main() { int x,y,z,r; x=1; y=2; try(x,y,z,r); cout<<r<<endl; return 0; } void try(int x,int y, int z,int r) { z = x+y; X = x*x; y = y*y; r = z+x+y; }
A.18
B.9
C.10
D.不确定
第5题:
求y=cos(x)从0到π的积分,正确的命令为_________。
A.int(y,x,0,pi)
B.int(x,0,pi)
C.int(x,y,0,pi)
D.int(0,pi,x,y)
第6题:
5、对于多个输入参数的函数也可以使用递归。下面哪个递归定义是正确的自然数加法?也就是说,对于自然数x,y,plus x y给出x+y。
A.plus :: Int -> Int -> Int plus 0 y = y plus x y = 1 + plus (x-1) y
B.plus :: Int -> Int -> Int plus x 0 = x plus x y = 1 + plus x (y-1)
C.plus :: Int -> Int -> Int plus x y = 1 + plus (x-1) y plus 0 y = y
D.plus :: Int -> Int -> Int plus 0 y = y plus x y = 1 + plus (x-1) (y-1)