Advertisement
Michal_Pilarski

zad10 tablice

Apr 17th, 2020
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.82 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. using namespace std;
  5.  
  6. void uzupelnianie(float tab[4][5])
  7. {
  8.     for(int i=0; i<4; i++)
  9.     {
  10.         for(int j=0; j<5; j++)
  11.         {
  12.             cout << "Podaj ocene: ";
  13.             cin >> tab[i][j];
  14.         }
  15.     }
  16. }
  17. void wyswietlanie(float tab[4][5])
  18. {
  19.     float srednia=0,poprzednia=0,uczen=0;
  20.     for (int i=0; i<4; i++)
  21.     {
  22.         srednia = 0;
  23.         for (int j=0; j<5; j++)
  24.     {
  25.  
  26.  
  27.         srednia = srednia + tab[i][j];
  28.  
  29.         if(srednia>=poprzednia)
  30.         {
  31.             poprzednia=srednia;
  32.             uczen=i;
  33.         }
  34.     }
  35.     }
  36.         cout << "Najwyzsza srednia wynosi: " << poprzednia/5 << ", ucznia nr." << uczen+1;
  37.  
  38. }
  39.  
  40. int main()
  41. {
  42.     float tabl[4][5];
  43.     uzupelnianie(tabl);
  44.     cout<<endl;
  45.     wyswietlanie(tabl);
  46.     return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement