代码如下:
#include<iostream.h>
int main()
{int a,b,sum;
a=2;
b=1;
sum=0;
while(a<=1000)
{
while(b<a)
{
if(a%b==0)
sum+=b;
else
goto;
b++;
}
if(sum==a)
cout<<a<<" ";
else
goto;
a++;
}
return 0;
}