C 语言求1000以内的完数 作者: Chuwen 时间: 2019-03-27 分类: C/C++ ``` #include #include int main() { int i, a, b; for(i=1; i<=1000; i++) { b=0; for(a=1; a<=i/2; a++){ if(i%a == 0){ b=b+a;//把求出的因子都加起来 } } if(b == i){ printf("%d its factors are ", i); for(a=1; a<=i/2; a++){ if(i%a == 0){ printf(",%d", a); } } printf("\n"); //printf("%d 是完数\n", i); } } } ``` 标签: none