Bugün buraya attım belki yarın birinin işine yarar..
PHP Kod:
#-*-coding:utf8;-*-
#qpy:2
#qpy:console
print "This is console module"
class stack:
def __init__(self, SIZE=50):
self.arr = []
self.top = 0
self.SIZE = SIZE
for i in range(self.SIZE):
self.arr.append(0)
def isEmpty(self):
if self.top==0:
return 1
else:
return 0
def isFull(self):
if self.top==self.SIZE:
return 1
else:
return 0
def push(self, val):
if not self.isFull():
self.arr[self.top] = val
self.top = self.top+1
return 0
else:
return -1
def pop(self):
if not self.isEmpty():
self.top = self.top-1
return self.arr[self.top]
else:
print "Stack is Empty!"
st = stack()
st.push(1)
st.push(2)
print st.pop()
print st.pop()