[백준] 4673번 : 셀프 넘버 - C

강재원·2022년 10월 19일
0

[코딩테스트] C/C++

목록 보기
129/200



https://www.acmicpc.net/problem/4673

#include<stdio.h>
static int d(int n){
    int num=n;
    while(n>0){
        num+=n%10;
        n/=10;
    }
    return num;
}

int main() {
    for(int i=1;i<=10000;i++){
        int count=0;
        for(int j=1;j<=10000;j++){
            if(i==d(j)){
                count=0;
                break;
            }
            else count=1;
        }
        if(count==1) printf("%d\n",i);
    }
}
profile
개념정리 & 문법 정리 & 알고리즘 공부

0개의 댓글