Advertisement
Guest User

zad 3

a guest
Oct 23rd, 2019
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.12 KB | None | 0 0
  1. int liczbaPartii = 10;
  2. int liczbaMantadow = 460;
  3. int[] glosy = new int[liczbaPartii];
  4. glosy[0] = 8051935;
  5. glosy[1] = 5060355;
  6. glosy[2] = 2319946;
  7. glosy[3] = 1578523;
  8. glosy[4] = 1256953;
  9. glosy[5] = 144773;
  10. glosy[6] = 32094;
  11. glosy[7] = 18918;
  12. glosy[8] = 5448;
  13. glosy[9] = 1765;
  14.  
  15.  
  16. int[] dzielnik = new int[10000];
  17. int[] mandaty = new int[liczbaPartii];
  18.  
  19. int Max_Gl = -10000;
  20. int Max_Pa = -1;
  21.  
  22. //na początku dla każdej partii iloraz równy 1
  23. for (int i = 0; i < liczbaPartii; i++)
  24. {
  25. dzielnik[i] = 1;
  26. }
  27.  
  28. for (int j = 0; j < liczbaMantadow; j++)
  29. {
  30. for (int i = 0; i < liczbaPartii; i++)
  31. {
  32. if (glosy[i] / dzielnik[i] > Max_Gl)
  33. {
  34. Max_Pa = i;
  35. Max_Gl = glosy[i] / dzielnik[i];
  36. }
  37. }
  38. dzielnik[Max_Pa]++;
  39. mandaty[Max_Pa]++;
  40. Max_Gl = 0;
  41.  
  42. }
  43. int suma = 0;
  44. //wyswietlenie
  45. for (int i = 0; i < liczbaPartii; i++)
  46. {
  47. Console.WriteLine(i+". Partia: " + mandaty[i]+ " mandatów");
  48. suma += mandaty[i];
  49. }
  50. Console.WriteLine("Mandatów było: " + suma);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement