왼쪽 오른쪽1 [프로그래머스][C++][0단계] 왼쪽 오른쪽 #include #include using namespace std; vector solution(vector str_list) { vector answer; for(int i = 0; i < str_list.size(); i++) { if(str_list[i] == "l") { for(int j = 0; j < i; j++) { answer.push_back(str_list[j]); } break; } if(str_list[i] == "r") { for(int j = i + 1; j < str_list.size(); j++) { answer.push_back(str_list[j]); } break; } } return answer; } 1. 주어진 벡터 str_list를 첫 원소부터 반복하면서 "l" .. 2023. 11. 2. 이전 1 다음