-
Notifications
You must be signed in to change notification settings - Fork 80
Expand file tree
/
Copy pathStack.py
More file actions
35 lines (27 loc) · 669 Bytes
/
Stack.py
File metadata and controls
35 lines (27 loc) · 669 Bytes
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
import random
class Stack:
def __init__(self):
self.top = -1
self.s = 100
self.S = [0 for i in range(0, self.s)]
def StackEmpty(self):
if self.top == -1:
return True
return False
def Push(self, x):
if self.top == self.s - 1:
return False
self.top += 1
self.S[self.top] = x
return True
def Pop(self):
if self.StackEmpty():
return False
else:
self.top -= 1
return self.S[self.top + 1]
S = Stack()
for i in range(0, 120):
S.Push(random.randint(0,999))
while not S.StackEmpty():
print S.Pop()