728x90
반응형
문자열 배열 strlist가 매개변수로 주어집니다. strlist 각 원소의 길이를 담은 배열을 retrun하도록 solution 함수를 완성해주세요.
#include <string>
#include <vector>
using namespace std;
vector<int> solution(vector<string> strlist) {
vector<int> answer;
for(int i = 0; i < strlist.size(); i++){
answer.push_back(strlist[i].length());
}
return answer;
}
이것은 문법을 알아야하는 문제였다
push_back 네녀석...문법이 중요하다.
length() 함수 : 배열의 길이를 구하는 함수인 것이다.
length() 자리에 size()를 넣어도 정답이 도출되었다.
728x90
반응형
'프로그래머스 C++ > Level.0' 카테고리의 다른 글
프로그래머스 C++ Level. 0 배열의 유사도 (0) | 2023.04.10 |
---|---|
프로그래머스 C++ Level. 0 최댓값 만들기(1) (0) | 2023.04.03 |
프로그래머스 C++ Level. 0 머쓱이보다 키 큰사람 (0) | 2023.03.22 |
프로그래머스 C++ Level. 0 짝수는 싫어요 (0) | 2023.03.18 |
프로그래머스 C++ Level. 0 짝수 홀수 개수 (0) | 2023.03.17 |