Advertisement
maycod23

Untitled

Mar 6th, 2023
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.46 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. int main() {
  5.  
  6. // int n; cin >> n;
  7. // vector<int> v(n);
  8. // for (auto &i : v) cin >> i;
  9.  
  10. // for (auto i : v) {
  11. // i = 0;
  12. // }
  13. // for (auto &i : v) cout << i;
  14.  
  15.  
  16. // set<int> s;//set syntax
  17. // for (auto &i : v) s.insert(i); //logn for insertion
  18. // //sorted , no duplicates
  19. // //only keys, no values
  20. // //logn
  21. // //no middle access
  22. // //only to iterate on elements;
  23. // //s.size(), s.insert(x), s.erase(s.find(x));,, how to iterate
  24.  
  25. // for (auto &i : s) cout << i << " "; cout << endl;
  26.  
  27. // // for (auto it = s.begin(); it != s.end(); it++)
  28. // // {
  29. // // cout << (*it) << endl;
  30. // // }
  31.  
  32. // int ele; cin >> ele;
  33. // s.erase(s.find(ele));
  34. // for (auto &i : s) cout << i << " "; cout << endl;
  35.  
  36.  
  37.  
  38.  
  39. // multiset<int> m1; //store in ascending order
  40.  
  41. // m1.insert(10); m1.insert(20); m1.insert(1); m1.insert(10);
  42. // for (auto i : m1) cout << i << " "; cout << endl;//1 10 10 20--multiset structure
  43.  
  44. // cout << m1.count(10) << endl;//frequency of 10->2
  45.  
  46. // m1.erase(10);//erased all instances/occurences of 10
  47. // for (auto i : m1) cout << i << " "; cout << endl;//-> 1 20
  48.  
  49. // m1.insert(10); m1.insert(10);
  50. // for (auto i : m1) cout << i << " "; cout << endl;//-> 1 10 10 20
  51.  
  52. // m1.erase(m1.find(10));//erased only single instance of 10
  53. // for (auto i : m1) cout << i << " "; cout << endl;//1 10 20
  54.  
  55. // auto it1 = m1.begin();
  56. // cout << *it1 << endl << endl << endl; //or*m1.begin()
  57.  
  58.  
  59.  
  60. /////////////////////////////////////////////////////////////////////////////////////
  61.  
  62. // multiset<int, greater<int>> m2; //store in descending order
  63.  
  64. // m2.insert(10); m2.insert(20); m2.insert(1); m2.insert(10);
  65. // for (auto i : m2) cout << i << " "; cout << endl;
  66.  
  67. // cout << m2.count(10) << endl;//ferqeuency of 10
  68.  
  69. // m2.erase(10);//erased all instances of 10
  70. // for (auto i : m2) cout << i << " "; cout << endl;
  71.  
  72. // m2.insert(10); m2.insert(10);
  73. // for (auto i : m2) cout << i << " "; cout << endl;
  74.  
  75. // m2.erase(m2.find(10));//erased only single instance of 10
  76. // for (auto i : m2) cout << i << " "; cout << endl;
  77.  
  78. // auto it2 = m2.begin();
  79. // cout << *it2 << endl;//or*m2.begin()
  80.  
  81.  
  82. int n; cin >> n;
  83. vector<int> v(n);
  84. for (int i = 0; i < n; i++) cin >> v[i];
  85.  
  86. stack<int> stk;
  87. for (int i = 0; i < n; i++) {
  88. stk.push(v[i]);
  89. }
  90.  
  91. while (!stk.empty()) {
  92. cout << stk.top() << " "; //top element of the stack
  93. stk.pop();
  94. }
  95. return 0;
  96. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement