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 30 31 32 33 34 35 36
|
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
vector<int> total;
vector<int> list1 = { 10,5,81,3,2,1,6,6,7};
vector<int> list2 = { 11,58,3,27,83,97,7,54,3 };
vector<int> vectorName;
vectorName.push_back(4);
vectorName.push_back(3);
vectorName.push_back(2);
vectorName.push_back(20);
vectorName.resize(2);
vectorName.pop_back();
for (int i = 0; i < vectorName.size(); i++) {
cout << vectorName[i] << " ";
}
cout <<"sort list 1: "<< endl;
sort(list1.begin(), list1.end());
for (int a : list1) {
cout << a << " ";
}
cout << endl;
cout<< "merge: " << endl;
merge(list1.begin(),list1.end(), list2.begin(),list2.end(), back_inserter(total);//this is the main culprit
for (int a : total) {
cout << a << " ";
}
//cout << vectorName[0] << endl;
//cout << vectorName[1] << endl;
system("pause");
return 0;
}
|