int gcd(int a,int b) { while (b!=0) { a=a%b; int temp=a; a=b; b=temp; } return a; } 即两个数中大的与小的求模,然后交换,直到余数为零……