网友您好, 请在下方输入框内输入要搜索的题目:

题目内容 (请给出正确答案)

【简答题】为以下程序段设计一组测试用例,要求分别满足语句覆盖、判定覆盖、条件覆盖。 int test(int A,int B) { if((A>1) AND (B<10)) then X=A-B; if((A=2) OR (B>20)) then X=A+B; return x; }


参考答案和解析
C
更多 “【简答题】为以下程序段设计一组测试用例,要求分别满足语句覆盖、判定覆盖、条件覆盖。 int test(int A,int B) { if((A>1) AND (B<10)) then X=A-B; if((A=2) OR (B>20)) then X=A+B; return x; }” 相关考题
考题 有以下程序:includeint f(int x){int y;if(x==0||x==1)return(3);y=x*x-f(x-2);return 有以下程序: #include<stdio.h> int f(int x) {int y; if(x==0||x==1)return(3); y=x*x-f(x-2); return y; } main() {int z; z=f(3);printf("%d\n",z); } 程序的运行结果是( )。A.0B.9C.6D.8

考题 ● 给定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

考题 给定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)个测试用例。A.3B.4C.5D.8

考题 有以下程序int fa(int x){return x*x;}int fb(int x){return x*x*x;}int f(int(*fl)(),int(*f2)(),int x}{return f2(x)-f1(x);}main(){int i;i=f(fa,fb,2);printf("%d\n",i);}程序运行后,输出结果是【 】。

考题 为使该程序执行结果为10,那么应该在程序划线处填入的语句是()。includeusing namespac 为使该程序执行结果为10,那么应该在程序划线处填入的语句是( )。 #include<iostream> using namespace std; class MyClass { public: MyClass (int a) { x=a; } ___________ //取x值 private: int x; }; int main() { MyClass my(10); cout<<my.GetNum()<<end1; return 0; }A.return x;B.int GetNum(){ return x;}C.intreturn x;D.void GetNum(){return x;}

考题 针对以下C语言程序段,假设sta[10]=-1,对于x的取值,需要______个测试用例能够满足分支覆盖的要求。int MathMine(int x){int m=0;int i;for(i=x-1; i<=x+1; i++){if (i<0) continue;if (i>31) break;if (sta[i]=-1) m++;}return m;}A.3B.4C.5D.6A.B.C.D.

考题 有如下程序:includeint func(int a, int b){return(a+b) ;}void main( ){int x=2,y 有如下程序: #include<iostream.h> int func(int a, int b) { return(a+b) ;} void main( ) { int x=2,y=5,z=8,r; r=func(func(x,y) ,z) ; cout < < r; } 该程序的输出的结果是A.12B.13C.14D.15

考题 类A定义如下: class A { private int x=10; int getx() { return x;} } class B extends A { private int x=15; //需要覆盖getx()方法 } 在下述方法中可以在类B中覆盖getx()方法的是 ( )A.int getx(){…}B.int getx(float f){…}C.float getx(){…}D.double getx(float f){…}

考题 有以下程序 int fa(int x) { return x*x; } int fb(int x) { return x*x*x; } int f(int (*f1)(),int (*f2)(),int x) { return f2(x)-f1(x); } main() { int i; i-f(fa, fb,2); printf("%d \n",i); } 程序运行后的输出结果是A.4B.1C.4D.8

考题 有以下程序 int fa(int x) {return x*x;} int fb(int x) {return x*x*x;} int f(int(*f1)(),int(*f2)(),int x) { return f2(x)-f1(x);} main() {int i; i=f(fa,fb,2);pfintf(“%d\n”,i); } 程序运行后的输出结果是A.-4B.1C.4D.8

考题 有以下程序: #includestdio.h int f(int x); main( ) { int a,b=0; for(a=0;a3;a++) { b=b+f(a);putchar(A+b);} } int f(int x) { return x * x1; } 程序运行后的输出结果是( )。A.ABEB.BDIC.BCFD.BCD

考题 阅读下列说明,回答问题1至问题3,将解答填入的对应栏内。[说明]逻辑覆盖是通过对程序逻辑结构的遍历实现程序的覆盖,是设计白盒测试用例的主要方法之。以下代码由C浯言书写,请按要求回答问题。void cal (int n){int g, s, b, q;if( (n>1000) (n<2000) ){g=n % 10;s=n % 100 / 10;b=n / 100 % 10;q= n / 1000;if( (q+g) =={ s + b ) ){printf("%-5d",n);}}printf("\n");return;}请找出程序中所有的逻辑判断语句。请分析并给出分别满足100%DC(判定覆盖)和100%CC(条件覆盖)时所需的逻辑条件。假设n的取值范围是0<n<3000,请用逻辑覆盖法为n的取值设计测试用例,使用例集满足基本路径覆盖标准。请帮忙给出每个问题的正确答案和分析,谢谢!

考题 有以下程序:includeusing namespace std;int f(int x);int sum(int n){ int x,s=0; f 有以下程序: #include<iostream> using namespace std; int f(int x); int sum(int n) { int x,s=0; for(x = 0;x<=n;x++) s+=f(x); return s; } int f(int x) { return (x*x+1); } int main() { int a,b; cout<<"Enter a integer number:"; cin>>a; b=sum(a) ; cout<<a<<","<<b<<end1; return 0; } 如果输入数字3,其输出结果是( )。A.3,12B.3,16C.3,18D.4,20

考题 以下程序的输出结果是()。includeint m=13;int fun(int x,int y){int m=2;return(x*y-m 以下程序的输出结果是( )。 #include<stdio.h> int m=13; int fun(int x,int y) {int m=2; return(x*y-m); } main() {int a=7,b=6; printf("%d",fun(a,B)/m); }A.1B.3C.7D.10

考题 有以下程序:includeint fun(int x,int y){if(x==y)return(x);else return((x+y)/2);}m 有以下程序: #include<stdio.h> int fun(int x,int y) {if(x==y)return(x); else return((x+y)/2); } main() {int a=1,b=2,c=3; printf("%d\n",fun(2*a,fun(b,C))); } 程序运行后的输出结果是( )。A.2B.3C.4D.5

考题 ● 针对以下C语言程序段,假设sta[10]= -1,对于x的取值,需要__个测试用例能够满足分支覆盖的要求。 int MathMine( int x ) { int m = 0; int i; for( i = x-1; i = x + 1; i++ ) { if ( i 0 ) continue; if ( i 31 ) break; if ( sta[i] == -1 ) m++; } return m; }A.3B.4C.5D.6

考题 有以下程序: int f1(doubleA){return a*a;} int f2(int x,int y) {double a,b; a=f1(x); b=f1(y); return a+b; } main() {double w; w=f2(2.1,4.0); } 程序执行后,变量w的值是( )。A.20.21B.20C.20.0D.0.0

考题 请仔细阅读以下程序并完成要求。 If((a>2&&b4|| d 请仔细阅读以下程序并完成要求。If((a>2&&b<3)&&(c>4|| d<5)){Flag=1;}Else{Flag=0;)请分别按照语句覆盖、判定覆盖、条件覆盖、判定/条件覆盖测试用例。

考题 阅读下面程序:include fun (int a, int b){int c;c=a+b;return c;}void main(){int 阅读下面程序:#include <iostream.h>fun (int a, int b){int c;c=a+b;return c;}void main(){int x=6, y=7, z=8, r;r=fun( (x--, y++, x+y), z--);cout<<r<<end1;}则该程序的输出结果是( )。A.11B.20C.21D.31

考题 有一段程序如下,请设计测试用例以满足语句覆盖要求。 void DoWork (int x,int y,int z) { int k=0,j=0; if ( (x>3) } //语句块2 j=j%3; //语句块3 }

考题 采用白盒测试方法对下图进行测试,设计了4个测试用例:①(x=0,y=3), ②(x=1,y=2), ③(x=-1,y=2),④(x=3,y=1)。至少需要测试用例①②才能完成( )覆盖,至少需要测试用例①②③或①②④才能完成( )覆盖。A.语句 B.条件 C.判定\条件 D.路径 A.语句 B.条件 C.判定\条件 D.路径

考题 下列方法定义中,正确的是( )。A.int x(int a,b)B.double x(int a,int b) {return(a-b);){int w:w=a-b:}C.double x(a,b)D.int x (int a,int b) {return b}{return a-b;}

考题 下面程序输出的结果是( )。 include using namespace std; int test(int n1 下面程序输出的结果是( )。 #include<iostream> using namespace std; int test(int n1,int n2) {return n1 +n2;} float test (int f1,float f2){return f1-f2;} float test(float x,float y){return(x+y)/2;} float test(float x,int y){return(x+y)*2;} void main(){ int a1=10; float a2=2.5f; cout<<test(a1,a2); }A.12.5B.7.5C.6.25D.25

考题 有如下程序: include using namespace std; int fun1(int x) {return++x;} int fun2(i 有如下程序:include<iostream>using namespace std;int fun1(int x) {return++x;}int fun2(int x) {return++x;}int main(){int x=1,y=2;y=fun 1(fun2(x));cout<<X<<','<<y;return 0:}程序的输出结果是______。

考题 ● 针对下列程序段,需要(58)个测试用例可以满足分支覆盖的要求。int IsLeap(int year){if ( year % 4 == 0 ){if ( ( year % 100 == 0 ){if ( year % 400 == 0 )leap = 1;elseleap = 0;}elseleap = 1;}elseleap = 0;return leap;}(58)A.3B.4C.6D.7

考题 针对下列程序段,需要( )个测试用例可以满足分支覆盖的要求。int IsLeap(int year){if(year%4==0){if((year%100==0){if(year%400==0)leap=1;else leap=0;}else leap=l;}else leap=0;return leap;}A.3 B.4 C.6 D.7

考题 请为下面的程序设计符合判定覆盖的测试用例。 int main() { int a,b,c,x,y,z,t; scanf(“d%,d%,d%”,a,b,c,t); if a5 t1 x=10 else x=1; if b10 y=20 else y=2; if c15 z=30 else z=3; printf(“d%,d%,d%/n”,x,y,z) }

考题 问答题请为下面的程序设计符合判定覆盖的测试用例。 int main() { int a,b,c,x,y,z,t; scanf(“d%,d%,d%”,a,b,c,t); if a5 t10 y=20 else y=2; if c15 z=30 else z=3; printf(“d%,d%,d%/n”,x,y,z) }