In this exercise I am using Visual Studio 2019 and a modified version of the std_lib_facilities header found here.
Chapter 21 // Drill 3.1
Read some floating-point values (at least 16 values) from a file into a vector<doubles> called vd.
Chapter 21 // Drill 3.2
Output vd to cout.
Chapter 21 // Drill 3.3
Make a vector vi of type vector<int> with the same number of elements as vd; copy the elements from vd into vi.
Chapter 21 // Drill 3.4
Output the pairs of (vd[i], vi[i]) to cout, one pair per line.
Chapter 21 // Drill 3.5
Output the sum of the elements of vd.
Chapter 21 // Drill 3.6
Output the difference between the sum of the elements of vd and the sum of the elements of vi.
Chapter 21 // Drill 3.7
There is a standard library algorithm called reverse that takes a sequence (pair of iterators) as arguments; reverse vd, and output vd to cout.
Chapter 21 // Drill 3.8
Compute the mean value of the elements in vd; output it.
Chapter 21 // Drill 3.9
Make a new vector<double> called vd2 and copy all elements of vd with values lower than (less than) the mean into vd2.
Chapter 21 // Drill 3.10
Sort vd, output it again.
With drill 9 I found out about std::copy_if():
https://en.cppreference.com/w/cpp/algorithm/copy
https://en.cppreference.com/w/cpp/algorithm/copy
No comments:
Post a Comment