/** 2. Write a function print() that prints a vector
of ints to cout. Give it two arguments: a string
for “labeling” the output and a vector.

3. Create a vector of Fibonacci numbers and print
them using the function from exercise 2. To
create the vector, write a function,
fibonacci(x,y,v,n), where integers x and y are ints,
v is an empty vector<int>, and n is the number of
elements to put into v; v[0] will be x and v[1]
will be y. A Fibonacci number is one that is part
of a sequence where each element is the sum
of the two previous ones. For example, starting with
1 and 2, we get 1, 2, 3, 5, 8, 13, 21, . . . .
Your fibonacci() function should make such a
sequence starting with its x and y arguments.

5. Write two functions that reverse the order of
elements in a vector<int>. For example, 1, 3, 5,
7, 9 becomes 9, 7, 5, 3, 1. The first reverse
function should produce a new vector with the
reversed sequence, leaving its original vector
unchanged. The other reverse function should
reverse the elements of its vector without using
any other vectors (hint: swap).
*/
#include "std_lib_facilities.h"

vector<int> reverse1(const vector<int> & v) {
    vector<int> reversed;
    for(int i = v.size()-1; i >= 0; --i)
        reversed.push_back(v[i]);
    return reversed;
}

void reverse2(vector<int> & v) {
    for(int i = 0; i < v.size()/2; ++i)
        swap(v[i],v[v.size()-1-i]);
}

void print(vector<int> v, string s) {
    cout << s << ": ";
    for(int x: v)
        cout << x << " ";
}

void fibonacci(int x, int y, vector<int> & v, int n) {
    v.push_back(x);
    v.push_back(y);
    for(int i = 0; i < n-1; ++i)
        v.push_back(v[i]+v[i+1]);
}

int main() {
    vector<int> Fib, Lucas, LucasBack;
    fibonacci(1,2,Fib,50);
    fibonacci(2,1,Lucas,10);
    print(Fib,"Fibonacci numbers");
    cout << endl;
    print(Lucas, "Lucas numbers");
    LucasBack = reverse1(Lucas);
    cout << endl;
    print(LucasBack, "Reverse Lucas");
    cout << endl;
    reverse2(LucasBack);
    print(LucasBack, "Double switcheroo");

}
