Skip to content

Commit bafe738

Browse files
authored
Merge pull request #138 from 18ankitjha/adding_Stack
added stack to folder
2 parents 73dc739 + a1b60c1 commit bafe738

File tree

1 file changed

+49
-0
lines changed

1 file changed

+49
-0
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#include <bits/stdc++.h>
2+
using namespace std;
3+
4+
class Stack{
5+
public:
6+
int size;
7+
int top;
8+
int *arr;
9+
10+
int isempty(){
11+
if(top==-1){
12+
return 1;
13+
}
14+
return 0;
15+
}
16+
int isfull(){
17+
if(top==size-1){
18+
return 1;
19+
}
20+
return 0;
21+
}
22+
};
23+
24+
int main()
25+
{
26+
// Stack s;
27+
// s.size=80;
28+
// s.top=-1;
29+
// s.arr=new int[s.size];
30+
31+
Stack *s=new Stack;
32+
s->size=4;
33+
s->top=-1;
34+
s->arr=new int[s->size];
35+
36+
s->arr[++s->top]=4;
37+
s->arr[++s->top]=5;
38+
s->arr[++s->top]=8;
39+
s->arr[++s->top]=9;
40+
41+
if(s->isempty()){
42+
cout<<"The stack is empty";
43+
}
44+
else{
45+
cout<<"The stack is not empty";
46+
}
47+
48+
return 0;
49+
}

0 commit comments

Comments
 (0)