Skip to content

Instantly share code, notes, and snippets.

@austa
Created October 30, 2013 18:06
Show Gist options
  • Save austa/7237243 to your computer and use it in GitHub Desktop.
Save austa/7237243 to your computer and use it in GitHub Desktop.
# -*- 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