프로그래머스 12947 하샤드 수

Jmnote (토론 | 기여)님의 2024년 1월 2일 (화) 18:47 판 (새 문서: ==개요== {{프로그래머스|레벨=1|페이지=4|분류=연습문제}} ==C++== <syntaxhighlight lang='cpp'> #include <string> #include <vector> using namespace std; bool soluti...)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요[ | ]

프로그래머스 12947 하샤드 수

2 C++[ | ]

#include <string>
#include <vector>

using namespace std;

bool solution(int x) {
    int temp = x;
    int sum = 0;
    while(temp > 0) {
        sum += temp % 10;
        temp /= 10;
    }
    return x % sum == 0;
}
문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}