Pabon_SEC

stack

Aug 17th, 2015
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.61 KB | None | 0 0
  1. #include<iostream>
  2. #include<stack>
  3.  
  4. using namespace std;
  5.  
  6. stack<int>st;
  7.  
  8. int main()
  9. {
  10.     st.push(1);
  11.     st.push(2);
  12.     st.push(3);
  13.     st.push(4);
  14.  
  15.     st.pop();              // 4 delete হয়ে গিয়েছে ।
  16.  
  17.     cout<<st.top()<<endl;  // stack এর top value এখন  3 ।
  18.  
  19.     cout<<"\nPrinting remaining values of stack :\n\n";
  20.  
  21.     while(!st.empty())
  22.     {
  23.         cout<<st.top()<<endl;
  24.  
  25.         st.pop();
  26.     }
  27.  
  28.     // এখানে empty() ফাংশনটি  স্ট্যাক খালি হয়েছে কিনা তা check করে ।
  29.  
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment