Advertisement
Guest User

Untitled

a guest
Dec 18th, 2014
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.64 KB | None | 0 0
  1. __author__ = 'Krzysztof'
  2. import random
  3.  
  4. def BubbleSort2(tab):
  5.     for i in range (len(tab)):
  6.         for j in range (len(tab)):
  7.             if tab[i].PESEL<tab[j].PESEL:
  8.                 temp = tab[j]
  9.                 tab[j] = tab[i]
  10.                 tab[i] = temp
  11.     return tab
  12.  
  13. def MergeSort(tab):
  14.     for i in range()
  15.  
  16.  
  17. def BubbleSort(tab):
  18.     for i in range(len(tab)):
  19.         for j in range(len(tab)):
  20.             if tab[i]<tab[j]:
  21.                 temp = tab[j]
  22.                 tab[j] = tab[i]
  23.                 tab[i] = temp
  24.     return tab
  25.  
  26. def  GenerowaniePESEL():
  27.     PESEL = str(random.randint(1,9))
  28.     PESEL += str(random.randint(0,9))
  29.     tmp = random.randint(1,12)
  30.     if tmp < 10:
  31.         PESEL += '0'
  32.         PESEL += str(tmp)
  33.     else:
  34.         PESEL += str(tmp)
  35.     tmp = random.randint(1,31)
  36.     if tmp < 10:
  37.         PESEL += '0'
  38.         PESEL += str(tmp)
  39.     else:
  40.         PESEL += str(tmp)
  41.     for i in range (0,5):
  42.         PESEL += str(random.randint(0,9))
  43.  
  44.     return PESEL
  45.  
  46. def WypiszPESEL(tab):
  47.     for i in range (len(tab)):
  48.         print tab[i].PESEL
  49.         print tab[i].Imie
  50.  
  51. class Osoba():
  52.  
  53.     PESEL = ''
  54.     Imie = ''
  55.     Nazwisko = ''
  56.  
  57.     def __init__(self, pesel, imie, nazwisko):
  58.         self.PESEL = pesel
  59.         self.Imie = imie
  60.         self.Nazwisko = nazwisko
  61.  
  62. rudy = Osoba('12323','krzysztof','biernacki')
  63. print rudy.Imie
  64.  
  65. tab = []
  66.  
  67.  
  68. for i in range(10):
  69.     tab.append(Osoba(GenerowaniePESEL(), str.format('Krzysztof{0}', i), 'Biernacki'))
  70.  
  71.  
  72. WypiszPESEL(tab)
  73.  
  74. print ('\n')
  75.  
  76. #for i in range(len(tab)):
  77. #    print tab[i].PESEL
  78.  
  79. BubbleSort2(tab)
  80.  
  81. WypiszPESEL(tab)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement