코딩테스트/프로그래머스
[Level 1][C++] 자연수 뒤집어 배열로 만들기
MJ.Lee
2024. 10. 10. 22:39
#include <string>
#include <vector>
using namespace std;
vector<int> solution(long long n) {
vector<int> answer;
while (true)
{
int a = n / 10;
int b = n % 10;
n = a;
answer.push_back(b);
if (a == 0)
break;
}
return answer;
}