MarcinKrol

Zad 10

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