#include<iostream>
#define Type int
#define MAXN 100
#define INF 10000
using namespace std;
class stack{
public :
stack(){
stackTop=-1;
maxStackItemIndex=-1;
}
void Push(Type x){
stackTop++;
if(stackTop>=MAXN)
cout<<"shuzuyejie";
else
{
StackItem[stackTop]=x;
if(x>Max()){
link2NextMaxItem[stackTop]=maxStackItemIndex;
maxStackItemIndex=stackTop;
}
else
link2NextMaxItem[stackTop]=-1;
}
}
Type Pop(){
Type ret;
if(stackTop<0)
cout<<"程序出错";
else{
ret=StackItem[stackTop];
if(stackTop==maxStackItemIndex){
maxStackItemIndex=link2NextMaxItem[stackTop];
}
stackTop--;
}
return ret;
}
Type Max(){
if(maxStackItemIndex>=0)
return StackItem[maxStackItemIndex];
else
return -INF;
}
bool Empty(){
if(stackTop=-1)
return true;
else
return false;
}
private:
Type StackItem[MAXN];
int stackTop;
int link2NextMaxItem[MAXN];
int maxStackItemIndex;
};
class Queue
{
public :
Type MaxValue(Type x,Type y)
{
if(x>y)
return x;
else
return y;
}
Type Queue::Max(){
return MaxValue(stackA.Max(),stackB.Max());
}
void EnQueue(Type v){
stackB.Push(v);
}
Type DeQueue(){
if(stackA.Empty())
{
while(!stackB.Empty())
stackA.Push(stackB.Pop());
}
return stackA.Pop();
}
private:
stack stackA;
stack stackB;
};
int main(){
Queue a;
a.EnQueue(15);
a.EnQueue(3);
a.EnQueue(50);
a.EnQueue(2);
cout<<a.Max();
return 0;
}