software_testing_work3_question1

 package com.Phantom;

 import java.io.IOException;
import java.util.Scanner; public class Work3_1 {
/**
* @param args
* @throws IOException
*/
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
Scanner in=new Scanner(System.in);
System.out.println("请输入两个数字");
int num1=in.nextInt();
int num2=in.nextInt();
System.out.println("最大公约数为>>>"+operation(num1,num2));
}
public static int operation(int a,int b) throws IOException {
int num=0;
for(int i=1; i<=a; i++){
if(b%i==0&&a%i==0){
num=i;
}
}
return num;
}
}

运行结果:

software_testing_work3_question1

findBugs:

software_testing_work3_question1software_testing_work3_question1

上一篇:jQuery获取Select option 选择的Text和 Value


下一篇:Linux 下磁盘挂载