#include<queue>
#include<iostream>
using namespace std;
class MyStack{
private:
queue<char> data;
queue<char> help;
public:
int size(){
return data.size();
}
bool push(char c){
data.push(c);
return true;
}
char top(){
return data.front();
}
void pop(){
if(data.size()!= 0){
data.pop();
while(data.size()>0){
help.push(data.front());
data.pop();
}
swap();
}
}
//交换两个队列的所有元素,即交换引用的意思
void swap(){
queue<char> tmp = data;
data = help;
help = tmp;
}
};
int main(){
MyStack s;
s.push('a');
s.push('b');
s.push('c');
cout << "push third time,the size is "<<s.size() << " the top is :" <<s.top() << endl;
s.pop();
cout << "pop one time,the size is "<<s.size() << " the top is :" <<s.top() << endl;
s.pop();
cout << "pop one time ,the size is "<<s.size() << " the top is :" <<s.top() << endl;
s.pop();
cout << "pop one time,the size is "<<s.size() << " the top is :" <<s.top() << endl;
return 0;
}