Advertisement
Imran_Mohammed

Stack

Jun 27th, 2022
107
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. int main()
  4. {
  5. //LIFO(Last In First Out)
  6.  
  7. //Declare :
  8. stack<int> st;
  9. st.push(1);
  10. st.push(2);
  11. st.push(3);
  12. st.push(1);
  13. st.push(4);
  14. st.push(3);
  15.  
  16. //Top element output & Delete :
  17. cout << st.top() << endl;
  18. st.pop();
  19.  
  20. cout << st.size() << endl;
  21.  
  22. while (!st.empty() ){
  23. cout << st.top() << " ";
  24. st.pop();
  25. }
  26.  
  27. return 0;
  28. }
  29.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement