문제: 정수가 들어 있는 배열 num_list가 매개변수로 주어집니다. num_list의 원소의 순서를 거꾸로 뒤집은 배열을 return하도록 solution 함수를 완성해주세요.
#include <string>
#include <vector>
using namespace std;
vector<int> solution(vector<int> num_list) {
vector<int> answer;
for(int i = num_list.size()-1; i>=0; i--) {
answer.push_back(num_list[i]);
}
return answer;
}
출처: 프로그래머스 https://school.programmers.co.kr/learn/courses/30/lessons/120821?language=cpp
'밥벌이 > 코딩테스트' 카테고리의 다른 글
프로그래머스 문자열 뒤집기(6/100) (0) | 2022.12.12 |
---|---|
프로그래머스 배열 원소 길이(5/100) (0) | 2022.12.12 |
프로그래머스 피자 나눠 먹기(나누기) (4/100) (0) | 2022.12.12 |
프로그래머스 범위기반 for문 (3/100) (0) | 2022.12.05 |
프로그래머스-코딩입문-두수의차 (1/100) (0) | 2022.12.04 |