Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- MAX_SIZE = 100
- stack = [ 0 ] * MAX_SIZE
- stack_size = 0
- def push(x):
- global stack_size
- print('ok')
- stack[stack_size] = x
- stack_size += 1
- def back():
- print( stack[stack_size-1] )
- def pop():
- global stack_size
- back()
- stack_size -= 1
- def size():
- print( stack_size )
- def clear():
- global stack_size
- print('ok')
- stack_size = 0
- while True:
- command = input()
- if command == 'exit':
- print('bye')
- break
- elif command[:4] == 'push':
- push(command.split()[1])
- else:
- exec( command + "()" )
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement