// 精簡版
 
public class JPA03 {
    public static void main(String[] args) {
        java.util.Scanner s = new java.util.Scanner(System.in);
        int a,b,i;
        while(true){
            System.out.println("Input:");  
            if((i = (a = s.nextInt()))==999) break;            
            b = s.nextInt();            
            while(!(a%i==0&&b%i==0)) i--;  
            System.out.println(i);
        }
    }
}
 
//-------------------------------------------------
 
import java.util.*;
 
public class JPA03 {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int a,b,i;
        while(true){
            System.out.println("Input:");
            a = s.nextInt();  
            if(a==999){
                break;
            }
            b = s.nextInt();
            i=a;
            while (true){
                if (a%i==0&&b%i==0){
                    break;
                }
                else{
                    i=i-1;
                }
            }
            System.out.println(i);
        }
    }
}
arrow
arrow
    全站熱搜

    黃彥霖 發表在 痞客邦 留言(2) 人氣()