728x90
반응형
SMALL
#include <string>
#include <vector>
using namespace std;
int solution(int n) {
int answer = 0;
string n_str = to_string(n);
for(auto c : n_str)
answer += c - '0';
return answer;
}
728x90
반응형
LIST
'C++' 카테고리의 다른 글
[프로그래머스] 삼각형의 완성조건 (1) (0) | 2025.09.03 |
---|---|
[프로그래머스] 머쓱이보다 키 큰 사람 (0) | 2025.09.03 |
[프로그래머스] 최댓값 만들기 (0) | 2025.09.03 |
[프로그래머스] 세균증식 (0) | 2025.09.03 |
[프로그래머스] 편지 (0) | 2025.09.02 |
댓글