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

Function main

Exercises/NoModules/Chapter 10/Soln10_06.cpp:16–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14void show(const std::vector<T>& data, size_t width = 5);
15
16int main()
17{
18 std::vector<int> numbers{ -2, 4, -5, 6, 10, -40, 56, 4, 67, 45 };
19 show(numbers);
20 sort(numbers);
21 std::cout << "\nSorted integers:\n";
22 show(numbers);
23
24 std::cout << "\nCharacters to be sorted:\n";
25 std::vector<char> letters{ 'C', 'd', 'a', 'z', 't', 'S', 'p', 'm', 'D', 'f' };
26 show(letters, 2);
27 sort(letters);
28 std::cout << "\nSorted characters:\n";
29 show(letters, 2);
30
31 std::cout << "\nFloating-point values to be sorted:\n";
32 std::vector<double> values{ -2.5, 1.4, -2.55, 6.3, 10.1, -40.5, 56.0, 4.7, 67.3, 45.0 };
33 show(values, 10);
34 sort(values);
35 std::cout << "\nSorted floaating-point values:\n";
36 show(values, 10);
37}
38
39template <typename T>
40void swap(std::vector<T>& data, size_t first, size_t second)

Callers

nothing calls this directly

Calls 2

showFunction · 0.70
sortFunction · 0.70

Tested by

no test coverage detected