1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #include <string> #include <vector> #include <algorithm> using namespace std; vector<int> solution(long long n) { vector<int> answer; string numbers_str = to_string(n); for(int i = 0; i < numbers_str.length(); i++){ answer.push_back(numbers_str[i] - '0'); } reverse(answer.begin(), answer.end()); return answer; } | cs |
'Problem-solving > 프로그래머스' 카테고리의 다른 글
프로그래머스 - 정수 제곱근 판별 (C++) (0) | 2020.03.13 |
---|---|
프로그래머스 - 정수 내림차순으로 배치하기 (C++) (0) | 2020.03.13 |
프로그래머스 - 자릿수 더하기 (C++) (0) | 2020.03.12 |
프로그래머스 - 이상한 문자 만들기 (C++) (0) | 2020.03.12 |
프로그래머스 - 약수의 합 (C++) (0) | 2020.03.06 |
댓글