MCPcopy Create free account
hub / github.com/Apress/beginning-cpp20 / largest

Function largest

Examples/Modules/Chapter 09/Ex9_03A.cpp:36–42  ·  view source on GitHub ↗

Finds the largest of a span of values

Source from the content-addressed store, hash-verified

34
35// Finds the largest of a span of values
36double largest(std::span<const double> data)
37{
38 double max {data[0]};
39 for (auto value : data)
40 if (max < value) max = value;
41 return max;
42}
43
44// Finds the largest of a vector of int values
45int largest(std::span<const int> data)

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected