We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 73dc739 + a1b60c1 commit bafe738Copy full SHA for bafe738
DSA/DSA-CPP/Stacks/implementingstackusingarray.cpp
@@ -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
19
20
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
49
+}
0 commit comments