求一个数所有约数的方法 下面介绍一种求nnn的所有因数的方法。 void ben(int n) { for(int i=1;i<=sqrt(n);i++) { if(n%i==0) { a[++cnt]=i; if(n!=i*i) a[++cnt]=n/i; } } }