Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Stack:
- def __init__(self, MaxSize):
- self.data = [0] * MaxSize
- self.top = 0
- def push(self, elem):
- self.data[self.top] = elem
- self.top +=1
- print("ok")
- def pop(self):
- self.top -=1
- print("self.data[self.top]")
- self.data[self.top] = 0
- def back(self):
- print(self.data[self.top] - 1)
- def size(self):
- print(self.top)
- MaxSize = 100
- def clear(self, MaxSize):
- self.data = [0] * MaxSize
- self.top = 0
- q = Stack(100)
- s = input()
- while True:
- if "push" in s:
- q.push(int(s.split()[1]))
- elif s == "pop":
- q.pop()
- elif s == "back":
- q.back()
- elif s == "size":
- q.size()
- elif s == "clear":
- q.clear()
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement