Vous êtes sur la page 1sur 2

GENESIS D.

APOLONIO
CEIT-03-601E

#include<iostream>
#include<string> if(top == -1)
using namespace std; {
cout<<endl<<"WARNING! Stack is
UNDERFLOW!\n\n";
class array again();
{ }
string num[15]; else
int top,max; {
char ans; string n=num[top];
char n[10]; top--;
cout<<endl<<"Deleted Element is : ";
public: cout<<n;
array() cout<<endl;
{
top = -1; }
max = 14; menu();
} }
void push();
void pop(); void array::display()
void display(); {
void again(); cout<<endl;
void menu(); if(top == -1)
}; {
void array::push() cout<<endl<<"Stack is Empty!\n\n";
{ again();
cin>>n; }
if(top == max) else
{ {
cout<<endl<<"WARNING!Stack is Overflow! for(int i=top;i>=0;i--)
CANNOT BE INSERTED!\n"; cout<<num[i]<<endl;
again(); cout<<" ";
} cout<<endl;
else }
{ }
top++; void array::menu()
num[top]=n; {
again(); char ch;
} string n;
menu();
}
void array::pop()

{
cout<<endl<<"\t*************MENU*********** case 'N':
**\n" case 'n':menu();
<<endl<<"\tpress [A] to ADD AN default:cout<<"INVALID
ELEMENT(PUSH)" INPUT!"<<endl;menu();
<<endl<<"\tpress [D] to DELETE AN
ELEMENT(POP)" }
<<endl<<"\tpress [V] to VIEW STACKS" }
<<endl<<"\tpress [E] to EXIT\n" void main()
<<endl<<"\tENTER YOUR CHOICE: "; {
cin>>ch; array a;
cout<<"\t*******************************"<<endl
; a.menu();
}
switch(ch)
{
case 'A':
case 'a':cout<<"Enter the element you want
to add: ";
push();
break;
case 'D':
case 'd':pop();
break;
case 'V':
case 'v':display();
break;
case 'E':
case 'e':cout<<endl<<"Exiting
Program"<<endl;
exit(0);
default: cout<<endl<<"INVALID ENTRY!";
system ("cls");
}

menu();
}

void array::again()
{
char ans;

cout<<"Do you wish to continue? [Y/N] : ";


cin>>ans;
switch(ans)
{
case 'Y':
case 'y':menu();
break;

Vous aimerez peut-être aussi