locale-test/9-4-2-201309060289-wanghuiy.../王惠宇第三次上机作业/03.cpp

27 lines
345 B
C++

#include<iostream.h>
int main()
{
int x,sum,a;
for(x=1;x<1000;x++)
{
sum=0;
for(a=1;a<x;a++)
{
if(x%a==0)
sum=sum+a;
}
if(sum==x)
{
cout<<x<<" its factors are ";
for(a=1;a<x;a++)
{
if(x%a==0)
cout<<a<<',';
}
cout<<'\n';
}
}
return 0;
}