parkdaehun   4년 전

#include

int main() {

int a = 0, b = 1, c = 0, d = 1, e = 0, aa[1000] = {0, };

while (1) {

scanf("%d", &a);

if (a == -1) {

break;

}

while (b < a) {

if (a % b == 0) {

aa[c] = b;

c++;

e = e + b;

}

b++;

}

if (e == a) {

printf("%d = %d", a, aa[0]);

while (d < c) {

printf(" + %d", aa[d]);

aa[d] = 0;

d++;

}

}

else {

printf("%d is NOT perfect.", a);

}

printf("\n");

b = 1;

c = 0;

d = 1;

e = 0;

}

return 0;

}

jh05013   4년 전

게시판은 연습장이 아닙니다.

jhnah917   4년 전

BOJ 에는 각 문제별로 [메모] 라는 좋은 기능이 존재합니다!

댓글을 작성하려면 로그인해야 합니다.