Created
April 16, 2016 09:21
-
-
Save tanvir002700/0bd0a42a4140f6e400810534b5714e40 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<iostream> | |
#include<stack> | |
#include<stdlib.h> | |
using namespace std; | |
int main() | |
{ | |
stack<int>S; | |
for(int i=0;i<5;i++) | |
{ | |
int x=rand()%100; | |
cout<<"Push: "<<x<<endl; | |
S.push(x); | |
} | |
cout<<"Stack size: "<<S.size()<<endl; | |
cout<<"Top element: "<<S.top()<<endl; | |
S.pop(); | |
cout<<"After pop top element: "<<S.top()<<endl; | |
while(!S.empty())S.pop(); | |
cout<<"Is stack empty: "<<S.empty()<<endl; | |
return 0; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Push: 83 | |
Push: 86 | |
Push: 77 | |
Push: 15 | |
Push: 93 | |
Stack size: 5 | |
Top element: 93 | |
After pop top element: 15 | |
Is stack empty: 1 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment