[C언어/C++] 4673: 셀프 넘버

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream>
 
using namespace std;
 
int NoneSelf(int n) {
    int result = n;
    while (n > 0) {
        result = result + n % 10;
        n = n / 10;
    }
 
    return result;
}
 
int main(void) {
    
    int data[10001= { 0, }, NoneSelfN;
 
    for (int i = 0; i < 10001; i++) {
        
        NoneSelfN = NoneSelf(i);
 
        if (NoneSelfN < 10001) {
            data[NoneSelfN] = 1;
        }
    }
 
    for (int i = 0; i < 10001; i++) {
        if (data[i] != 1) {
            cout << i << endl;
        }
    }
}
cs

관련글

in-coder 커뮤니티 HOT게시물

제목 작성자 작성일