Created
October 30, 2013 18:06
-
-
Save austa/7237243 to your computer and use it in GitHub Desktop.
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
# -*- coding: utf-8 -*- | |
#İkili tabana donusturme | |
class Stack: | |
def __init__(self): | |
self.liste = [] | |
def isEmpty(self): | |
return self.liste == [] | |
def push(self, eklenen): | |
self.liste.append(eklenen) | |
def pop(self): | |
return self.liste.pop() | |
def size(self): | |
return len(self.liste) | |
def ikiliyeCevir(sayi): | |
s = Stack() | |
while sayi > 0: | |
kalan = sayi % 2 | |
s.push(kalan) | |
sayi = sayi / 2 | |
yeniString = "" | |
while not s.isEmpty(): | |
yeniString = yeniString + repr(s.pop()) | |
return yeniString | |
print ikiliyeCevir(57) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment