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

Function main

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

Source from the content-addressed store, hash-verified

21std::string largest(std::span<std::string> words);
22
23int main()
24{
25 double array[] {1.5, 44.6, 13.7, 21.2, 6.7};
26 std::vector numbers {15, 44, 13, 21, 6, 8, 5, 2};
27 std::vector data{3.5, 5.0, 6.0, -1.2, 8.7, 6.4};
28 std::array array_data{ 3.5, 5.0, 6.0, -1.2, 8.7, 6.4 }; // Throwing in an std::array for good measure
29 std::vector<std::string> names {"Charles Dickens", "Emily Bronte",
30 "Jane Austen", "Henry James", "Arthur Miller"};
31 std::cout << "The largest of array is " << largest(array) << std::endl;
32 std::cout << "The largest of numbers is " << largest(numbers) << std::endl;
33 std::cout << "The largest of data is " << largest(data) << std::endl;
34 std::cout << "The largest of array_data is (also) " << largest(array_data) << std::endl;
35 std::cout << "The largest of names is " << largest(names) << std::endl;
36}
37
38// Finds the largest of a span of values
39double largest(std::span<double> data)

Callers

nothing calls this directly

Calls 1

largestFunction · 0.70

Tested by

no test coverage detected