안녕 세상아,

[프로그래머스/c++] LV1 하샤드 본문

프로그래머스

[프로그래머스/c++] LV1 하샤드

돈 많은 백수가 되고싶다 2024. 7. 30. 14:40

https://school.programmers.co.kr/learn/courses/30/lessons/12947

 

프로그래머스

코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요.

programmers.co.kr

각 자리수 더하고 주어진 수에 나눠서 나머지가 없으면 true..

#include <string>
#include <vector>

using namespace std;

bool solution(int x) {
    bool answer = true;
    
    string str=to_string(x);
    int cnt=0;
    
    for(int i=0;i<str.size();i++){
        int a=str[i]-'0';
        cnt+=a;
    }
    if(x%cnt==0)
        answer=true;
    else
        answer=false;
    return answer;
}

프로그래머스는 왜 자동 줄맞춤이 안되는걸까...? 구려...

암튼 일단은 쉬우니까 이번주 안에 1단계는 끝내는걸로 하자~ 친해지깅