aa
#include<iostream>
using namespace std;
class CStack
{
public:
CStack()
{
top = 0;
size = 10;
a=new int[10];
cout<<"Constructor."<<endl;
}
CStack(int s)
{
top = 0;
size = s;
a = new int[s];
cout << "Constructor." << endl;
}
int get(int index)
{
return *(a + index);
}
void push(int n)
{
a[top++] = n;
}
int isEmpty()
{
if (top == 0)
return 1;
else
return 0;
}
int isFull()
{
if (top == size)
return 1;
else
return 0;
}
int pop()
{
return *(a + (--top));
}
~CStack()
{
delete []a;
cout<<"Destructor."<<endl;
}
private:
int *a;
int size;
int top;
};
int main()
{
int t;
cin >> t;
int test, p;
for (int i = 0; i < t; i++)
{
cin >> test;
CStack CStack1(test);
for (int j = 0; j < test; j++)
{
cin >> p;
CStack1.push(p);
}
if (1 == CStack1.isEmpty())
cout << "empty" << endl;
else if (1 == CStack1.isFull())
{
for (int j = 0; j < test - 1; j++)
cout << CStack1.pop() << " ";
cout << CStack1.pop() << endl;
}
}
return 0;
}