Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- using namespace std;
- double srednia_nzer(const vector<double> & t){
- int i;
- int rozmiar = t.capacity();
- double suma =0;
- for(i=0;i<rozmiar;i++){
- if(t[i] !=0) {
- suma += t[i];
- }
- }
- suma = suma/rozmiar;
- return suma;
- }
- int main()
- {
- vector<double> a;
- a.reserve(5);
- a[0] = 9;
- a[1] = 10;
- a[2] = 10;
- a[3] = 10;
- a[4] = 10;
- cout << srednia_nzer(a)<< endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement