实验三

1、

import java.io.BufferedReader;

import java.io.IOException;

import java.io.InputStreamReader;

public class ApproximateName {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
int a = 0;
System.out.print("请输入m:");
BufferedReader strin=new BufferedReader(new InputStreamReader(System.in));
try {
a=Integer.parseInt(strin.readLine());

} catch (NumberFormatException e) {

// TODO Auto-generated catch block

e.printStackTrace();

} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
int b = 0;

System.out.print("请输入一个n:");
BufferedReader strin2=new BufferedReader(new InputStreamReader(System.in));
try {
b=Integer.parseInt(strin2.readLine());
} catch (NumberFormatException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
int flag = 0;
for (int i = 1; i <= a; i++) {
if(a%i==0){
if(b%i==0){
flag=i;}
}
}
System.out.println("最大公约数为"+flag);
}
}

2、

Private Judge(){

Public static void main(string[]args){

Scanner scanner =new Scanner(System.in) ;

Int x=scanner.nextInt();

Int y=scanner.nextInt();

Int result=scanner.nextInt();

If(x<4 or y>0)

{

   If(y>1){

     Y=y+1;

     }

   Else{

Return result;

}

Else{

   If(x>=5){

X=x-y;

}

Else

{

X=x+y

}

}

语句覆盖:

X=6         y=0             路径aef

X=1          y=2            路径abc

分支覆盖:

X=6/4      y=1             路径aef/aeg

X=1       y=2/1              路径abc/abd

 

 

posted @ 2016-05-13 10:49  李光洙洙洙  阅读(148)  评论(0编辑  收藏  举报