stacks c++ code
hello!! can you plzz give an example code, just a simple code for stacks ..
what are stacks?
queue and stacks sir!!
i have my queue code that`s why i`ll need stacks.. can you give some example code for stacks sir?
I think you need to explain yourself a bit clearer before anyone can help you..
What is the program you're trying to run? What is it designed to do?
If you have queue code then what's the problem??? It's much easier to program a stack as compared to queue.
just a simple code for stacks |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
void push(int y)
{
if(top>stackSize)
{
cout<<"stack full"<<endl;
return;
}
else
{
top++;
stack[top]=y;
}
}
int pop()
{
int a;
if(top<=0)
{
cout<<"stack is empty"<<endl;
return 0;
}
else
{
a=stack[top];
top--;
}
return(a);
}
| |
Topic archived. No new replies allowed.