33 lines
817 B
Python
33 lines
817 B
Python
|
#!/usr/bin/python
|
||
|
|
||
|
class obliczanieMandatow(object):
|
||
|
@staticmethod
|
||
|
def test(komitety, glosy, mandaty):
|
||
|
glosy_kopia = list(glosy)
|
||
|
dzielniki_glosy = [ 1 for i in range(len(glosy_kopia)) ]
|
||
|
while(mandaty != 0):
|
||
|
index = 0
|
||
|
max = glosy_kopia[0]
|
||
|
for i in range(1,len(glosy_kopia)):
|
||
|
if(glosy_kopia[i]>=max):
|
||
|
if(glosy_kopia[i]==max):
|
||
|
if(glosy[i]>glosy[index]):
|
||
|
max = glosy_kopia[i]
|
||
|
index = i
|
||
|
else:
|
||
|
max = glosy_kopia[i]
|
||
|
index = i
|
||
|
dzielniki_glosy[index] = dzielniki_glosy[index] + 1
|
||
|
print glosy_kopia[index], '', komitety[index]
|
||
|
glosy_kopia[index] = glosy[index] / dzielniki_glosy[index]
|
||
|
mandaty = mandaty - 1
|
||
|
|
||
|
mandaty = 8
|
||
|
list_glosy = [720, 300, 480]
|
||
|
list_komitety = ['A', 'B', 'C']
|
||
|
obliczanieMandatow.test(list_komitety, list_glosy, mandaty)
|
||
|
|
||
|
|
||
|
"""
|
||
|
|
||
|
"""
|