- import java.util.Scanner;
- public class JPA02 {
- public static void main(String[] args) {
- int a, b;
- try {
- Scanner sc = new Scanner(System.in);
- a=sc.nextInt();
- b=sc.nextInt();
- if(a<0 || a>100 || b<0 || b>100 )
- {
- System.out.print("error");
- return;
- }
- } catch (Exception e) {
- System.out.print("error");
- return;
- }
- while(a%b!=0)
- {
- int tmp=a%b;
- a=b;
- b=tmp;
- }
- System.out.println(b);
- }
- }
複製代碼 |