Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CPP

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;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #average #vector
ADD COMMENT
Topic
Name
8+4 =