#include<iostream.h>
#include<conio.h>
#define size 5
int stack[size],top=-1;
void push(int s[size],int &t,int m);
int pop (int s[size],int &t);
void main()
{
clrscr();
cout<<"1-push \n 2-pop \n 3-exit \n";
int x,y;
do
{
cout<<"enter number to choice:";
cin>>x;
switch(x)
{
case 1:
cout << "enter anumber to push in stack \n";
cin >> y;
push(stack, top, y)
break;
case 2:
y = pop(stack, top);
if(y == -1)
cout << "\n empty \n";
else
cout << "\n popis ok \n y=" << y << "\n";
break;
}
} while( x != 3 );
getch();
}
void push(int s[size], int &t, int m)
{
if(t == size-1)
cout << "the stack is full \n";
else
s[++t] = m;
}
int pop(int s[size], int &t)
{
if(t==-1)
return -1;
else
return s[t--];
}
abbashadwan 0 Newbie Poster
Moschops 683 Practically a Master Poster Featured Poster
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
mike_2000_17 2,669 21st Century Viking Team Colleague Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
NathanOliver 429 Veteran Poster Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
NathanOliver 429 Veteran Poster Featured Poster
Tumlee 42 Junior Poster in Training
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
deceptikon 1,790 Code Sniper Team Colleague Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
deceptikon commented: ;) +12
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.