标签:style blog color os ar java for sp div
1 /* 2 * 求两个数的最大公约数 3 */ 4 5 import java.util.Scanner; 6 7 8 public class Zy4 { 9 public static void main(String[] args) { 10 Scanner as=new Scanner(System.in); 11 Scanner zx=new Scanner(System.in); 12 int a=(int) as.nextDouble(); 13 int b=(int) zx.nextDouble(); 14 int small=0,ma=0; 15 if(a<b){ 16 small=a; 17 ma=b; 18 } 19 else small=b; 20 ma=a; 21 for(int i=small;i>1;--i){ 22 if(ma%i==0&&small%i==0){ 23 System.out.println(i); 24 } 25 break; 26 } 27 as.close(); 28 zx.close(); 29 } 30 }
标签:style blog color os ar java for sp div
原文地址:http://www.cnblogs.com/Wqwwd/p/4029772.html