class Stack {
int max;
int top;
int* stk;
public:
Stack(int max=10) : max(max), top(0), stk(new int[max]) {}
~Stack() { delete[] stk; }
bool Push(int x) {
if (IsFull()) return false;
stk[top++] = x;
return true;
}
int Pop() { return stk[--top]; }
void Clear() { top = 0; }
int Search(int x) const {
for (int i = top - 1; i >= 0; i--)
if (stk[i] == x) return i;
return -1;
}
bool IsFull() const { return top >= max; }
bool IsEmpty() const { return top == 0; }
int Peek() const { return stk[top-1]; }
int Capacity() const { return max; }
int Size() const { return top; }
};
#include <iostream>
using namespace std;
int main() {
Stack s;
s.Push(3);
s.Push(9);
s.Push(54);
while (!s.IsFull())
s.Push(1);
cout << s.Peek() << endl;
cout << s.Pop() << endl;
cout << s.Search(54) << endl;
while (!s.IsEmpty())
s.Pop();
cout << s.Capacity() << endl;
cout << s.Size() << endl;
}