Advertisement
Holek

Untitled

May 20th, 2017
47
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. using namespace std;
  4. double srednia_nzer(const vector<double> & t){
  5. int i;
  6. int rozmiar = t.capacity();
  7. double suma =0;
  8. for(i=0;i<rozmiar;i++){
  9. if(t[i] !=0) {
  10. suma += t[i];
  11. }
  12. }
  13. suma = suma/rozmiar;
  14. return suma;
  15. }
  16. int main()
  17. {
  18. vector<double> a;
  19. a.reserve(5);
  20. a[0] = 9;
  21. a[1] = 10;
  22. a[2] = 10;
  23. a[3] = 10;
  24. a[4] = 10;
  25. cout << srednia_nzer(a)<< endl;
  26. return 0;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement