limun11

Untitled

Sep 20th, 2015
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.39 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. void unos(int[]);
  5. int igrac(int [][4]);
  6. float prosjecna(int[][4], int);
  7.  
  8. const int red = 5, kolona = 4;
  9.  
  10. int main()
  11. {
  12.  
  13. int matrica[red][kolona];
  14. int n = 0;
  15.  
  16. for (int i = 0; i < kolona; i++)
  17. {
  18. unos(matrica[i]);
  19.  
  20. }
  21. cout << "Igrac koji je postigao najvise nula poena je igrac broj: " << igrac(matrica) << endl;
  22.  
  23. cout << "Prosjecan broj na toj utakmici je: " << prosjecna(matrica, n) << endl;
  24. system("PAUSE");
  25. return 0;
  26. }
  27.  
  28. void unos(int matrica[])
  29. {
  30. cout << "Unesite poene za igraca:" << endl;
  31. for (int i = 0; i < red; i++)
  32. {
  33. cout << "Igrac broj: " << i << " je ostvario poena: ";
  34. cin >> matrica[i];
  35.  
  36. while (matrica[i] < 0)
  37. {
  38. cout << "Igrac ne moze imati manji broj poena od 0! Ponovite unos: " << endl;
  39. cin >> matrica[i];
  40. }
  41. }
  42. }
  43.  
  44. int igrac(int matrica[][4])
  45. {
  46. int max = 0;
  47. int zamjena = 0;
  48.  
  49. for (int i = 0; i < red; i++)
  50. {
  51. for (int j = 0; j < kolona; j++)
  52. {
  53. if (matrica[i][j] == 0)
  54. return i;
  55. else
  56. cout << "Nema igraca s nulom!" << endl;
  57. }
  58.  
  59. }
  60.  
  61. }
  62.  
  63.  
  64. float prosjecna(int matrica[][4], int n)
  65. {
  66. float prosje = 0;
  67. cout << "Izaberite utakmicu za koju zelite znati prosjecan broj poena: " << endl;
  68. cin >> n;
  69. for (int i = 0; i < red; i++)
  70. {
  71. for (int j = 0; j < kolona; j++)
  72. {
  73. prosje = prosje + (matrica[i][n] / 4);
  74. }
  75. }
  76. return prosje;
  77. }
Advertisement
Add Comment
Please, Sign In to add comment