Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define ll long long
- int main() {
- // int n; cin >> n;
- // vector<int> v(n);
- // for (auto &i : v) cin >> i;
- // for (auto i : v) {
- // i = 0;
- // }
- // for (auto &i : v) cout << i;
- // set<int> s;//set syntax
- // for (auto &i : v) s.insert(i); //logn for insertion
- // //sorted , no duplicates
- // //only keys, no values
- // //logn
- // //no middle access
- // //only to iterate on elements;
- // //s.size(), s.insert(x), s.erase(s.find(x));,, how to iterate
- // for (auto &i : s) cout << i << " "; cout << endl;
- // // for (auto it = s.begin(); it != s.end(); it++)
- // // {
- // // cout << (*it) << endl;
- // // }
- // int ele; cin >> ele;
- // s.erase(s.find(ele));
- // for (auto &i : s) cout << i << " "; cout << endl;
- // multiset<int> m1; //store in ascending order
- // m1.insert(10); m1.insert(20); m1.insert(1); m1.insert(10);
- // for (auto i : m1) cout << i << " "; cout << endl;//1 10 10 20--multiset structure
- // cout << m1.count(10) << endl;//frequency of 10->2
- // m1.erase(10);//erased all instances/occurences of 10
- // for (auto i : m1) cout << i << " "; cout << endl;//-> 1 20
- // m1.insert(10); m1.insert(10);
- // for (auto i : m1) cout << i << " "; cout << endl;//-> 1 10 10 20
- // m1.erase(m1.find(10));//erased only single instance of 10
- // for (auto i : m1) cout << i << " "; cout << endl;//1 10 20
- // auto it1 = m1.begin();
- // cout << *it1 << endl << endl << endl; //or*m1.begin()
- /////////////////////////////////////////////////////////////////////////////////////
- // multiset<int, greater<int>> m2; //store in descending order
- // m2.insert(10); m2.insert(20); m2.insert(1); m2.insert(10);
- // for (auto i : m2) cout << i << " "; cout << endl;
- // cout << m2.count(10) << endl;//ferqeuency of 10
- // m2.erase(10);//erased all instances of 10
- // for (auto i : m2) cout << i << " "; cout << endl;
- // m2.insert(10); m2.insert(10);
- // for (auto i : m2) cout << i << " "; cout << endl;
- // m2.erase(m2.find(10));//erased only single instance of 10
- // for (auto i : m2) cout << i << " "; cout << endl;
- // auto it2 = m2.begin();
- // cout << *it2 << endl;//or*m2.begin()
- int n; cin >> n;
- vector<int> v(n);
- for (int i = 0; i < n; i++) cin >> v[i];
- stack<int> stk;
- for (int i = 0; i < n; i++) {
- stk.push(v[i]);
- }
- while (!stk.empty()) {
- cout << stk.top() << " "; //top element of the stack
- stk.pop();
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement