Advertisement
Guest User

Q

a guest
Oct 21st, 2019
143
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.82 KB | None | 0 0
  1. class Stack:
  2.     def __init__(self, MaxSize):
  3.         self.data = [0] * MaxSize
  4.         self.top = 0
  5.  
  6.     def push(self, elem):
  7.         self.data[self.top] = elem
  8.         self.top +=1
  9.         print("ok")
  10.  
  11.     def pop(self):
  12.         self.top -=1
  13.         print("self.data[self.top]")
  14.         self.data[self.top] = 0
  15.    
  16.     def back(self):
  17.         print(self.data[self.top] - 1)
  18.    
  19.     def size(self):
  20.         print(self.top)  
  21.  
  22.     MaxSize = 100    
  23.     def clear(self, MaxSize):
  24.         self.data = [0] * MaxSize
  25.         self.top = 0
  26.    
  27.  
  28. q = Stack(100)
  29. s = input()
  30. while True:
  31.     if "push" in s:
  32.         q.push(int(s.split()[1]))
  33.     elif s == "pop":
  34.         q.pop()
  35.     elif s == "back":
  36.         q.back()
  37.     elif s == "size":
  38.         q.size()
  39.     elif s == "clear":
  40.         q.clear()
  41.     break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement