이 문제에서 숫자 입력을 배열 형태의 텍스트로 받기 때문에, 여기서 숫자를 분리해야 한다.
[1,2,3,4] -> 숫자 1,2,3,4 분리
string str, word;
vector<string> words;
str.erase(location); // location = str.begin() + (제거할 위치 - 1)
stringstream ss(str);
while(getline(ss, word, )){
words.push_back(word); // str을 ',' 기준으로 토큰화 -> 하나씩 words에 저장
}
< 참고자료 >
'알고리즘, 자료구조' 카테고리의 다른 글
[알고리즘] 시간 복잡도 (0) | 2023.08.20 |
---|---|
[알고리즘] 재귀 (0) | 2023.08.17 |
[알고리즘] 이분 탐색 (0) | 2023.05.15 |
[자료구조][C++] Stack, Queue, Deque (0) | 2023.04.25 |