-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstack_array_str.h
58 lines (48 loc) · 1.08 KB
/
stack_array_str.h
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#include<iostream>
using namespace std;
int push(char *arrstring,int top,char ch)//pass the address of the string array,top index of the stack
{
arrstring[++top]=ch;
return top;
}
char pop(char *arrstring,int top)//pass the address of the string array,top index of the stack
{
return arrstring[top--];
}
char display_top(char *arrstring,int top)//pass the address of the string array,top index of the stack
{
return arrstring[top];
}
void display(char *arrstring,int top)//pass the address of the string array,top index of the stack
{
if(top==-1){
cout<<"\n stack is empty";
}else
{
cout<<"\n top "<<"\n :\n";
for(int i=top;i>=0;i--)
{
cout<<"| "<<arrstring[i]<<" |"<<"\n";
}
}
}
int isfull(int top,int arrsize){
if((top+1)==arrsize)//top+1 as top array starts from 0
{
return 1;
}
else
{
return 0;
}
}
int isempty(int top){
if(top==-1)
{
return 1;
}
else
{
return 0;
}
}