求最大公约数,用欧几里得算法(辗转相除法)。 int gcd(int a,int b){ return b==0 ? a : gcd(b,a%b); } 转载于:https://www.cnblogs.com/shenchuguimo/p/6359851.html