Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <queue>
- using namespace std;
- int main()
- {
- queue <int> s;
- char c;
- int y;
- while (true){
- cin>>c>>y;
- if (c=='a'){
- s.push(y);
- }
- if (c=='d'){
- if(!s.empty()) {
- cout<<s.front()<<endl;
- s.pop();
- }
- else{
- cout<<"the stack is empty"<<endl;
- break;
- }
- }
- if ((c!='a') && (c!='d')) {
- while(!s.empty()){
- cout<<s.front()<<endl;
- s.pop();
- }
- break;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement