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

Function main

Exercises/NoModules/Chapter 19/Soln19_02/Soln19_02.cpp:20–42  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 2

listFunction · 0.70
sortFunction · 0.70

Tested by

no test coverage detected