You are on page 1of 2

# include <iostream>

using namespace std;

bool isfull(int i,int j)


{
if(i==j-1)
return true;
else
return false;

}
//back:
bool Pop(int i)
{
if(i==-1)
return true;
else
return false;

}
int main()
{
int top=-1;
int x;
int a[100];
cout<<"enter the size of element"<<endl;
cin>>x;

cout<<"enter the elemnts"<<endl;


for(int i=0;i<100;i++)
{
if(isfull(top,x)== true )
{
cout<<"is full"<<endl;
goto o;
}
else
{
top++;
cin>> a[top];

}
}
o:
cout<<"the elemnts after enter"<<endl;
for(int j=0;j<x;j++)
{
cout<<a[top]<< endl;
top--;
}
top=x-1;
// for delete
cout<< " delete the elemnt in the stack array"<<endl;
int y;
first:
if(Pop(top)== true)
{
cout<<"is emity"<<endl;
goto out;

}
else
{
insid:
cout<<"enter the last elemnt"<<endl;
cin>>y;
cout<<"___________________________"<<endl;
if (y!=a[top])
{
cout<<"most be enter the last elemnt "<<endl;
goto insid;
}
else
{
int z=top-1;
cout<<" after delete "<<endl;
for(int i=0; i<top;i++)
{
cout<<a[z]<<endl;

z--;
}
cout<<"..........................."<<endl;
top--;
goto first;
}

}
out:
system("pause");
return 0;
}

You might also like