//
// main.cpp
// Stack
//
// Created by Himanshu on 03/10/21.
//
#include <iostream>
#include <stack>
using namespace std;
int main () {
stack<int> st;
cout<<"Push(x) {10, 20, 30, 40, 50}"<<endl;
st.push(10);
st.push(20);
st.push(30);
st.push(40);
st.push(50);
cout<<"Stack-Empty(): ";
if (st.empty()) {
cout<<"Stack is empty"<<endl;
} else {
cout<<"Stack is not empty"<<endl;
}
cout<<"Pop elements..."<<endl;
while (!st.empty()) {
cout<< st.top()<<" ";
st.pop();
}
cout<<endl;
cout<<"Stack-Empty(): ";
if (st.empty()) {
cout<<"Stack is empty"<<endl;
} else {
cout<<"Stack is not empty"<<endl;
}
return 0;
}
Ly8KLy8gIG1haW4uY3BwCi8vICBTdGFjawovLwovLyAgQ3JlYXRlZCBieSBIaW1hbnNodSBvbiAwMy8xMC8yMS4KLy8KCiNpbmNsdWRlIDxpb3N0cmVhbT4KI2luY2x1ZGUgPHN0YWNrPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKaW50IG1haW4gKCkgewogICAgCiAgICBzdGFjazxpbnQ+IHN0OwogICAgCiAgICBjb3V0PDwiUHVzaCh4KSB7MTAsIDIwLCAzMCwgNDAsIDUwfSI8PGVuZGw7CiAgICBzdC5wdXNoKDEwKTsKICAgIHN0LnB1c2goMjApOwogICAgc3QucHVzaCgzMCk7CiAgICBzdC5wdXNoKDQwKTsKICAgIHN0LnB1c2goNTApOwoKICAgIGNvdXQ8PCJTdGFjay1FbXB0eSgpOiAiOwogICAgaWYgKHN0LmVtcHR5KCkpIHsKICAgICAgICBjb3V0PDwiU3RhY2sgaXMgZW1wdHkiPDxlbmRsOwogICAgfSBlbHNlIHsKICAgICAgICBjb3V0PDwiU3RhY2sgaXMgbm90IGVtcHR5Ijw8ZW5kbDsKICAgIH0KICAgIAogICAgY291dDw8IlBvcCBlbGVtZW50cy4uLiI8PGVuZGw7CiAgICB3aGlsZSAoIXN0LmVtcHR5KCkpIHsKICAgICAgICBjb3V0PDwgc3QudG9wKCk8PCIgIjsKICAgICAgICBzdC5wb3AoKTsKICAgIH0KICAgIGNvdXQ8PGVuZGw7CiAgICAKICAgIGNvdXQ8PCJTdGFjay1FbXB0eSgpOiAiOwogICAgaWYgKHN0LmVtcHR5KCkpIHsKICAgICAgICBjb3V0PDwiU3RhY2sgaXMgZW1wdHkiPDxlbmRsOwogICAgfSBlbHNlIHsKICAgICAgICBjb3V0PDwiU3RhY2sgaXMgbm90IGVtcHR5Ijw8ZW5kbDsKICAgIH0KICAgIAogIHJldHVybiAwOwp9