In this exercise I am using Visual Studio 2017 and the std_lib_facilities header provided by Stroustrup.
Chapter 18 // Vector Drills1 - Define a global vector<int> gv; initialise it with ten ints, 1, 2, 4, 8, 16, etc.
2 - Define a function f() taking a vector<int> argument.
3 - In f():
a. Define a local vector<int> lv with the same number of elements as the argument vector.
b. Copy the values from gv into lv.
c. Print out the elements of lv.
d. Define a local vector<int> lv2; initialise it to be a copy of the argument vector.
e. Print out the elements of lv2.
4. In main():
a. Call f() with gv as its argument.
b. Define a vector<int> vv, and initialise it with the first ten factorial values (1, 2*1, 3*2*1, 4*3*2*1, etc.).
c. Call f() with vv as its argument.
Oh I love vector. You can just get on with your life.
No comments:
Post a Comment