#include <iostream>
#include <algorithm>
#include <stack>
using namespace std;
class MyQueue
{
private:
stack<int> s1;
stack<int> s2;
public:
MyQueue();
~MyQueue();
void push_back(int);
void pop_front();
int fornt();
int back();
bool isempty();
int size();
};
MyQueue::MyQueue()
{
}
MyQueue::~MyQueue()
{
}
void MyQueue::push_back(int elem){
s1.push(elem);
}
void MyQueue::pop_front(){
for (int i = s1.size() - 1; i > 0; i--){
s2.push(s1.top());
s1.pop();
}
s1.pop();
for (int i = s2.size(); i > 0; i--)
{
s1.push(s2.top());
s2.pop();
}
}
int MyQueue::fornt(){
for (int i = s1.size() - 1; i > 0; i--){
s2.push(s1.top());
s1.pop();
}
int tmp = s1.top();
for (int i = s2.size(); i > 0; i--)
{
s1.push(s2.top());
s2.pop();
}
return tmp;
}
int MyQueue::back(){
return s1.top();
}
bool MyQueue::isempty(){
if (s1.empty())
{
return true;
}
return false;
}
int MyQueue::size(){
return s1.size();
}
void test(){
MyQueue Q;
Q.push_back(12);
Q.push_back(20);
Q.push_back(14);
Q.push_back(8);
Q.push_back(21);
Q.push_back(3);
cout<<Q.back()<<endl;
cout<<Q.fornt()<<endl;
cout<<Q.size()<<endl;
cout<<Q.isempty()<<endl;
int sizeof_MyQueue = Q.size();
for (int i = 0; i < sizeof_MyQueue; i++)
{
Q.pop_front();
}
cout<<Q.size()<<endl;
cout<<Q.isempty()<<endl;
}
int main(void){
test();
return 0;
}