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

Function main

Exercises/Modules/Chapter 19/Soln19_02/Soln19_02.cpp:23–45  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

21}
22
23int main()
24{
25 std::vector numbers{ -2, 4, -5, 6, 10, -40, 56, 4, 67, 45 };
26 std::cout << "\nIntegers to be sorted:\n";
27 list(numbers);
28 sort(numbers, std::greater<>{});
29 std::cout << "\nSorted integers:\n";
30 list(numbers);
31
32 std::cout << "\nCharacters to be sorted:\n";
33 std::vector letters{ 'C', 'd', 'a', 'z', 't', 'S', 'p', 'm', 'D', 'f' };
34 list(letters, 2);
35 sort(letters, [](char x, char y) { return std::tolower(x) < std::tolower(y); });
36 std::cout << "\nSorted characters:\n";
37 list(letters, 2);
38
39 std::cout << "\nFloating-point values to be sorted:\n";
40 std::vector values{ -2.5, 1.4, -2.55, 6.3, 10.1, -40.5, 56.0, 4.7, 67.3, 45.0 };
41 list(values, 10);
42 sort(values, [](double x, double y) { return std::abs(x) < std::abs(y); });
43 std::cout << "\nSorted floaating-point values:\n";
44 list(values, 10);
45}

Callers

nothing calls this directly

Calls 2

listFunction · 0.70
sortFunction · 0.50

Tested by

no test coverage detected