实验3

第一题:

import java.util.Scanner;


public class demo {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub

Scanner scanner = new Scanner(System.in);
System.out.print("请输入第一个数a:");
int a = scanner.nextInt();
System.out.print("请输入第二个数b:");
int b = scanner.nextInt();
int c=a%b;
a=b;
b=c;
if(c!=0){
a=b;
b=c;
}
else
System.out.println("a,b的最大公约数为:"+a);
}
}

 

 

第二题

语句覆盖:

路径:a-e-g  测试用例:x=4 y=-1  输出结果:x=3 y=-1 

   a-e-f        x=6 y=-1         x=7 y=-1

   a-b-c          x=3 y=2           x=3 y=3

分支覆盖:

路径:a-e-g  测试用例:x=4 y=-1  输出结果:x=3 y=-1 

   a-e-f        x=6 y=-1         x=7 y=-1

   a-b-d       x=3 y=1                     x=3 y=1

   a-b-c          x=3 y=2           x=3 y=3

posted @ 2016-04-13 00:01  hw20  阅读(109)  评论(0编辑  收藏  举报