Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import wpf
- from System.Windows import Application, Window, MessageBox
- class MyWindow(Window):
- def __init__(self):
- wpf.LoadComponent(self, 'Gen.xaml')
- def Generuj_Click(self, sender, e):
- size = self.dlugosc.Text
- first = self.firstvalue.Text
- if isinstance(size,int) == False or isinstance(first,int) == False or size<1 or first<0 :
- Messagebox.Show("To nie s¹ wartoci ca³kowite dodatnie!")
- else:
- gen(size,first)
- def gen(size = 20000,first = 0): # First jest elementem zerowym ci¹gu
- tablica = [first]
- ciag = ''
- a = 0x41C64E6D # Implementacja zgodna z ANSI C
- b = 12356
- m = 2 ** 32
- for i in xrange (1,size):
- tablica.append((a*tablica[i-1] + b) % m )
- ciag += (str(bin(tablica[i])[2:]))
- if len(ciag)>size:
- ciag[:size] # utworzenie z wylosowanych ci¹gów binarnych ci¹gu o d³ugoci size
- break
- self.hexval.Text = str(hex(int(ciag,2)))[2:].__str__()
- self.binval.Text = str(ciag).__str__()
- if __name__ == '__main__':
- Application().Run(MyWindow())
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement