返回列表 發帖
  1. import java.util.Scanner;
  2. public class Ch01 {

  3.         public static void main(String[] args) {
  4.                 // TODO 自動產生的方法 Stub
  5.                 int a,b;
  6.                 try{
  7.                         Scanner sc=new Scanner(System.in);
  8.                         a=sc.nextInt();
  9.                         b=sc.nextInt();
  10.                         if(a>100 || a<1 || b>100 || b<1){
  11.                                 System.out.println("error");
  12.                                 return;
  13.                         }
  14.                 }catch(Exception e){
  15.                         System.out.println("error");
  16.                         return;
  17.                 }
  18.                 while(a%b!=0){
  19.                         int temp=a%b;
  20.                         a=b;
  21.                         b=temp;
  22.                         System.out.println(b)
  23.                 }
  24.                
  25.         }

  26. }
複製代碼

TOP

返回列表