-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMarge.cpp
More file actions
26 lines (25 loc) · 751 Bytes
/
Marge.cpp
File metadata and controls
26 lines (25 loc) · 751 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
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
vector<int> stack1 = {50, 20, 10, 100, 200};
vector<int> stack2 = {500, 2000, 5000, 1000, 10000};
vector<int> stack3(10);
cout << "The original 1st stack: ";
for (int i = 0; i < 5; i++)
cout << stack1[i] << " ";
cout << endl;
cout << "The original 2nd stack: ";
for (int i = 0; i < 5; i++)
cout << stack2[i] << " ";
cout << endl;
sort(stack1.begin(), stack1.end());
sort(stack2.begin(), stack2.end());
merge(stack1.begin(), stack1.end(), stack2.begin(), stack2.end(),
stack3.begin());
cout << "The resultant stack of notes is: ";
for (int i = 0; i < stack3.size(); i++)
cout << stack3[i] << " ";
return 0;
}