-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathT76.cpp
More file actions
29 lines (24 loc) · 756 Bytes
/
Copy pathT76.cpp
File metadata and controls
29 lines (24 loc) · 756 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
//TODO merge 算法包里的 合并两个容器
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main76() {
vector<int> vectorVar1;
vectorVar1.push_back(10);
vectorVar1.push_back(20);
vectorVar1.push_back(30);
vectorVar1.push_back(40);
vector<int> vectorVar2;
vectorVar2.push_back(50);
vectorVar2.push_back(60);
vectorVar2.push_back(70);
vectorVar2.push_back(80);
vector<int> result;
result.resize(vectorVar1.size() + vectorVar2.size());
merge(vectorVar1.begin(), vectorVar1.end(), vectorVar2.begin(), vectorVar2.end(), result.begin());
for (auto it = result.begin(); it != result.end(); it++) {
cout << " merge " << *it << endl;
}
return 0;
}