Advertisement
MeehoweCK

Untitled

Sep 10th, 2018
210
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. double srednia(double* tablica, int wielkosc)
  6. {
  7.     double wartosc = 0;
  8.  
  9.     for(int i = 0; i < wielkosc; ++i)
  10.         wartosc = wartosc + tablica[i];
  11.  
  12.     return wartosc / wielkosc;
  13. }
  14.  
  15. int main()
  16. {
  17.     double tablica[5] = {1, 3.2, 5.1, -0.2, 0.97};
  18.     cout << srednia(tablica, 5);
  19.     return 0;
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement