KarolWozniak

Zadanie 10 tablice

Apr 16th, 2020
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. int tab1[4][5];
  10. float tab2[4];
  11. float naj;
  12.  
  13.     for(int i=0;i<4;i++)
  14.     {
  15.         float s=0;
  16.         for(int j=0;j<5;j++)
  17.         {
  18.             cin >> tab1[i][j];
  19.             s=s+tab1[i][j];
  20.  
  21.         }
  22.         s=s/5;
  23.         tab2[i]=s;
  24.         cout << "srednia wynosi: " << tab2[i] << endl;
  25.  
  26.     }
  27.  
  28.     naj=tab2[0];
  29.     int ucz=1;
  30.  
  31.     for(int i=0;i<4;i++)
  32.     {
  33.         if(naj<tab2[i])
  34.         {
  35.             naj=tab2[i];
  36.             ucz=ucz+1;
  37.         }
  38.  
  39.     }
  40.  
  41.     cout << "Uczen " << ucz << " Posiada najwieksza srednia, ktora wynosi: " << naj;
  42.  
  43.  
  44.  
  45.  
  46.     return 0;
  47.  
  48. }
Advertisement
Add Comment
Please, Sign In to add comment