웅재의 코딩세상

[프로그래머스] 5명씩 본문

코딩테스트/프로그래머스 - LV 0

[프로그래머스] 5명씩

웅드 2024. 1. 30. 17:11

 

 

  • 풀이
#include <string>
#include <vector>

using namespace std;

vector<string> solution(vector<string> names) {
    vector<string> answer;
    for(int i=0; i<names.size(); i++){
        if(i % 5 == 0) answer.push_back(names[i]);
    }
    return answer;
}
반응형