250x250
반응형
Notice
Recent Posts
Recent Comments
Link
목록뒤집기 (1)
N

자릿수 더하기 문제와 똑같은 유형이다..! while문으로 n이 0보다 작아질 때까지 반복한다. answer가 벡터이므로 push_back을 통해 값을 넣어주고, 나머지 연산을 이용하면 n을 뒤집어서 넣을 수 있다..! #include #include using namespace std; vector solution(long long n) { vector answer; while(n > 0) { answer.push_back(n % 10); n /= 10; } return answer; }
프로그래머스 알고리즘/1단계
2020. 4. 27. 10:40