#include <iostream>
int main( int argc, char* argv[] ) {
int s = 0;
for ( int i = 1; i <= 1000; i++ ) {
for ( int j = 1; j <= i; j++ ) {
if ( i % j == 0 ) {
s = s + j;
}
if ( s == i ) {
std::cout << "Perfect number: " << i << std::endl;
}
}
}
std::cin.get();
return 0;
}
- use iostream, not iostream.h
- do not use conio.h and its functions ( clrscr() and getche() ), because it's non-standard in C++. In one compiler it might work, in another it doesn't
- use int main with return 0;
- indent your code. That saves every reader of it an headache :)