-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10828.py
More file actions
39 lines (30 loc) · 760 Bytes
/
10828.py
File metadata and controls
39 lines (30 loc) · 760 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
36
37
38
39
class stack :
def __init__(self, length=10000):
self.items = []
self.top = 0
self.max = length
def push(self, x):
self.top += 1
self.items.append(x)
def pop(self):
if self.top == 0 :
print("-1")
else :
self.top -= 1
self.items.pop()
def size(self):
print(self.top)
def empty(self):
if self.top == 0 : print("1")
else : print("0")
def top(self):
if self.top == 0 : print("-1")
else :
result = self.items[self.top-1]
print(result)
a = stack()
command_num = input()
commands = []
for i in range(int(command_num)):
commands[i] = input()
a.commands[i]