코딩테스트/프로그래머스
[레벨1] 하샤드 수
marmelo12
2021. 8. 20. 20:14
반응형
#include <string>
#include <vector>
using namespace std;
bool solution(int x) {
bool answer = true;
int harshadNum = 0,temp = x;
while(temp > 0)
{
harshadNum += temp % 10;
temp /= 10;
}
if(x % harshadNum != 0)
answer = false;
return answer;
}
반응형