Пример #1
0
 void pop() {
     if(left.empty()) {
         while(!right.empty()) {
             left.push(right.top());
             right.pop();
         }
     }
     left.pop();
 }
Пример #2
0
 int top() {
     if(left.empty()) {
         while(!right.empty()) {
             left.push(right.top());
             right.pop();
         }
     }
     return left.top();
 }
Пример #3
0
    int min() {
        if(left.empty())
            return right.min();
        if(right.empty())
            return left.min();

        if(left.min() < right.min())
            return left.min();
        else
            return right.min();
    }
Пример #4
0
    int max() {
        if(left.empty())
            return right.max();
        if(right.empty())
            return left.max();

        if(left.max() > right.max())
            return left.max();
        else
            return right.max();
    }
Пример #5
0
 int empty() {
     if(left.empty() && right.empty())
         return 1;
     else
         return 0;
 }