[프로그래머스][Level1] 자릿수 더하기 c++
·
🍞 Problem Solving/Programmers
https://programmers.co.kr/learn/courses/30/lessons/12931 프로그래머스 코드 중심의 개발자 채용. 스택 기반의 포지션 매칭. 프로그래머스의 개발자 맞춤형 프로필을 등록하고, 나와 기술 궁합이 잘 맞는 기업들을 매칭 받으세요. programmers.co.kr 풀이과정 자연수 n을 string으로 바꾸고 각 자리수에 '0'을 빼줘서 문자를 숫자로 만든다. 숫자로 만든 것들을 반복문을 돌려 합을 구해준다. #include using namespace std; int solution(int n) { int answer = 0; string str = to_string(n); for(int i = 0; i < str.size(); i++){ answer += str[i]..