import java.util.*;
public class me{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int x,y,z;
while(sc.hasNext()){
x = sc.nextInt();
y = sc.nextInt();
z=gcd(x,y);
System.out.println(z);
}
}
public static int gcd(int x,int y){
if(x<y){
int t=x;
x=y;
y=t;
}
int b=x%y;
if(b==0)
return y;
else
return b;
}
}
再想想怎麼做吧..
照你的寫法
72和27的最大公因數是18???