#include
using namespace std;
int main( )
{
int n , temp , i , k , a[100] , sum ;
for( n = 1 ; n < 100 ; n ++ )
{
temp = n ;
k = 0 ;
sum = 0 ;
for( i = 1 ; i < n ; i ++ )
{
if( n % i == 0 )
{
a[k++] = i ;
sum += i ;
}
}
if( sum == n )
{
cout << n << endl ;
for( i = 0 ; i < k ; i ++ )
{
cout << a[i] << ' ' ;
}
cout << endl ;
}
}
return 0 ;
}
#include
using namespace std;
int main()
{
int i,j,k,sum,s[100];
i = 2;
while(i<=100)
{
j = 1;
k = 0;
sum = 0;
while(j {
if( i % j == 0 ) {s[k++] = j ;sum += j;}
j++;
}
if(sum == i)
{
cout<
{
cout< }
cout<
i++;
}
return 0;
}
如果都要用while的话中间的for可以改成这样
if(sum == i)
{
cout<
while(j
cout< }
cout<