Search
 
SCRIPT & CODE EXAMPLE
 

CPP

c++ vector average

double avg1(std::vector<int> const& v) {
    return 1.0 * std::accumulate(v.begin(), v.end(), 0LL) / v.size();
}
Comment

c++ average vector

float average(std::vector<float> const& v){
    if(v.empty()) return 0;
    auto const count = static_cast<float>(v.size());
    return std::reduce(v.begin(), v.end()) / count;
}
Comment

PREVIOUS NEXT
Code Example
Cpp :: system("pause") note working c++ 
Cpp :: toupper c++ 
Cpp :: how to make a square root function in c++ without stl 
Cpp :: c++ changing string to double 
Cpp :: c++ template 
Cpp :: how to initialize a queue in c 
Cpp :: how to make a function in c++ 
Cpp :: string comparison c++ 
Cpp :: overload array operator cpp 
Cpp :: c++ find index of all occurrences in string 
Cpp :: c++ find index of element in array 
Cpp :: c++ Attribute Parser 
Cpp :: fill vector with zeros c++ 
Cpp :: c++ program to print odd numbers using loop 
Cpp :: resharper fold statement 
Cpp :: why use python 
Cpp :: set size of a vector c++ 
Cpp :: size of string c++ 
Cpp :: input c++ 
Cpp :: log base e synthax c++ 
Cpp :: c++ generic pointer 
Cpp :: Split a number and store it in vector 
Cpp :: how to use power in c++ 
Cpp :: how to make a pointer point to a the last value in an array 
Cpp :: ex: cpp 
Cpp :: files c++ 
Cpp :: remove elements from vector 
Cpp :: c++ square and multiply algorithm 
Cpp :: progress indicator raytracer 
Cpp :: how to run cpp in visual studio 
ADD CONTENT
Topic
Content
Source link
Name
3+2 =