#include <stdio.h>
void getPerfectNumber(int n){
int k[100],kc = 0,ks=0;
for (int i=1;i<=n;i++){
for (int j=1;j<=i/2;j++){
if (i%j == 0)
k[kc++] = j;
}
for (int j=0;j<kc;j++){
ks += k[j];
k[j] = 0;
}
if (ks == i)
printf("%d\n", i);
kc = 0;
ks = 0;
}
}
int main ()
{
getPerfectNumber(1000);
return 0;
}
追问有bug啊 都没定义i,j
运行有错误 运行不出来😭