返回列表 發帖
  1. import java.util.Scanner;
  2. public class JPA02 {
  3.         public static void main(String[] args) {
  4.                 int a,b;
  5.                 try {
  6.                         Scanner sc=new Scanner(System.in);
  7.                             b=sc.nextInt();
  8.                             a=sc.nextInt();
  9.                             if(a>100 || a<1||b>100||b<1){
  10.                                     System.out.println("error");
  11.                                         return;
  12.                             }
  13.                 } catch (Exception e) {
  14.                         System.out.println("error");
  15.                         return;
  16.                 }
  17.                 while(a%b!=0){
  18.                         int temp=a%b;
  19.                         a=b;
  20.                         b=temp;
  21.                 }
  22.                 System.out.println(b);
  23.         }
  24. }
複製代碼

TOP

返回列表