#coding:utf-8
#author:Elvis
class Stack(object):
def __init__(self, size=8):
self.stack = []
self.size = size
self.top = -1
def is_empty(self):
if self.top == -1:
return True
else:
return False
def is_full(self):
if self.top +1 == self.size:
return True
else:
return False
def push(self, data):
if self.is_full():
raise Exception('stackOverFlow')
else:
self.top += 1
self.stack.append(data)
def stack_pop(self):
if self.is_empty():
raise Exception('stackIsEmpty')
else:
self.top -= 1
return self.stack.pop()
def stack_top(self):
if self.is_empty():
raise Exception('stackIsEmpty')
else:
return self.stack[self.top]
def show(self):
print self.stack
stack = Stack()
stack.push(1)
stack.push(2)
stack.push('a')
stack.push('b')
stack.push(5)
stack.push(6)
stack.stack_pop()
stack.stack_pop()
stack.stack_top()
stack.is_empty()
stack.is_full()
stack.show()
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有