Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- __author__ = 'Krzysztof'
- import random
- def BubbleSort2(tab):
- for i in range (len(tab)):
- for j in range (len(tab)):
- if tab[i].PESEL<tab[j].PESEL:
- temp = tab[j]
- tab[j] = tab[i]
- tab[i] = temp
- return tab
- def MergeSort(tab):
- for i in range()
- def BubbleSort(tab):
- for i in range(len(tab)):
- for j in range(len(tab)):
- if tab[i]<tab[j]:
- temp = tab[j]
- tab[j] = tab[i]
- tab[i] = temp
- return tab
- def GenerowaniePESEL():
- PESEL = str(random.randint(1,9))
- PESEL += str(random.randint(0,9))
- tmp = random.randint(1,12)
- if tmp < 10:
- PESEL += '0'
- PESEL += str(tmp)
- else:
- PESEL += str(tmp)
- tmp = random.randint(1,31)
- if tmp < 10:
- PESEL += '0'
- PESEL += str(tmp)
- else:
- PESEL += str(tmp)
- for i in range (0,5):
- PESEL += str(random.randint(0,9))
- return PESEL
- def WypiszPESEL(tab):
- for i in range (len(tab)):
- print tab[i].PESEL
- print tab[i].Imie
- class Osoba():
- PESEL = ''
- Imie = ''
- Nazwisko = ''
- def __init__(self, pesel, imie, nazwisko):
- self.PESEL = pesel
- self.Imie = imie
- self.Nazwisko = nazwisko
- rudy = Osoba('12323','krzysztof','biernacki')
- print rudy.Imie
- tab = []
- for i in range(10):
- tab.append(Osoba(GenerowaniePESEL(), str.format('Krzysztof{0}', i), 'Biernacki'))
- WypiszPESEL(tab)
- print ('\n')
- #for i in range(len(tab)):
- # print tab[i].PESEL
- BubbleSort2(tab)
- WypiszPESEL(tab)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement