728x90
SW Expert Academy
SW 프로그래밍 역량 강화에 도움이 되는 다양한 학습 컨텐츠를 확인하세요!
swexpertacademy.com
vector의 insert 함수를 활용해봤던 문제
// 20분
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main() {
int t = 10;
for (int tc = 1; tc <= t; tc++) {
vector<string> v;
int a;
cin >> a;
for (int i = 0; i < a; i++) {
string str;
cin >> str;
v.push_back(str);
}
cin >> a;
for (int i = 0; i < a; i++) {
int x, y;
string s;
char k;
cin >> k >> x >> y;
// x의 위치 바로 다음에 y개의 숫자를 삽입한다. 숫자는 s들이다.
vector<string>::iterator it1;
for (int j = 0; j < y; j++) {
it1 = v.begin();
it1 += x;
x++;
cin >> s;
v.insert(it1, s);
}
}
cout << "#" << tc << " ";
for (int i = 0; i < 10; i++) {
cout << v[i] << " ";
}
cout << endl;
}
}'swea > D3' 카테고리의 다른 글
| [swea] 2814 최장경로 (1) | 2024.04.18 |
|---|