Created
January 1, 2016 19:26
-
-
Save ozgurkaracam/745aeede9a64be702af2 to your computer and use it in GitHub Desktop.
iki stack'ın aynı olup olmadığını kontrol eden program
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Stack: | |
def __init__(self): | |
self.alist=[] | |
def pop(self): | |
return self.alist.pop() | |
def push(self,a): | |
self.alist.append(a) | |
def show(self): | |
return self.alist | |
def peek(self): | |
return self.alist[len(self.alist)-1] | |
def isempty(self): | |
return len(self.alist)==0 | |
def size(self): | |
return len(self.alist) | |
def aynimi(a,b): | |
dengeli=True | |
if a.size()!=b.size(): | |
return False | |
else: | |
if a.isempty() and b.isempty(): | |
return True | |
else: | |
while a.isempty()==False and b.isempty()==False: | |
if a.pop()!=b.pop(): | |
dengeli=False | |
break | |
return dengeli | |
s=Stack() | |
a=Stack() | |
s.push('a') | |
s.push('b') | |
print (aynimi(s,a)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment