用java编写程序输入两个整数,并输出这两个数的所有公约数

求全部过程 可用的

Scanner scan = new Scanner(System.in);
  System.out.println("输入两个数用\",\"分隔");
  String[] s = scan.nextLine().split(",");
  int a = Integer.parseInt(s[0]);
  int b = Integer.parseInt(s[1]);
  int count = a>=b?b:a;
  for(int i =1;i<=count;i++){
   if(a%i==0 && b%i==0){
    System.out.println(a+"和"+b+"的公约数有"+i);
   }
  }追问

?是什么意思

温馨提示:内容为网友见解,仅供参考
无其他回答
相似回答