Professional Documents
Culture Documents
#include <string>
#include "StackType.cpp"
int main()
{
StackType <int> st;
if( st.IsEmpty())
cout << "Stack is Empty." << endl;
else
cout << "Stack is not Empty." << endl;
int temp;
for(int i=0; i<4; i++)
{
cin >> temp;
st.Push(temp);
}
if( st.IsEmpty())
cout << "Stack is Empty." << endl;
else
cout << "Stack is not Empty." << endl;
if( st.IsFull())
cout << "Stack is Full." << endl;
else
cout << "Stack is not Full." << endl;
while (!(st.IsEmpty()))
{
st2.Push(st.Top());
st.Pop();
}
while (!(st2.IsEmpty()))
{
temp = st2.Top();
cout << temp << " ";
st.Push(temp);
st2.Pop();
}
cout << endl << "Enter a new item: " << endl;
while (!(st.IsEmpty()))
{
st2.Push(st.Top());
st.Pop();
}
while (!(st2.IsEmpty()))
{
temp = st2.Top();
cout << temp << " ";
st.Push(temp);
st2.Pop();
}
if( st.IsFull())
cout << "Stack is Full." << endl;
else
cout << "Stack is not Full." << endl;
st.Pop();
st.Pop();
temp = st.Top();
cout << temp << endl;
cout << "Enter a few parentheses '(' or ')' to check if it is balanced or not:
" << endl;