求公因数函数` 仅供参考 传入gcd(12,9) 1 return gcd(9,3) 2.return gcd(3,0) 3 .b=0所以return 3 int gcd(int a,int b){ if(b==0) return a; else return gcd(b,a%b); } 第二种非递归 int gcd(int a,int b){ int t; while(b){ t=a%b; a=b; b=t; } }