Define multiplication over positive integers, using only increment by 1, decrement by 1, add (from the previous page) and recursion.
Write a recursive definition of indexOf from the first page, for an unsorted Vector. You will need an extra parameter:
Why is this version less desirable than the iterative version?
What does the following print? Can you draw a diagram of the state of the world at each output point?
(For the solution, copy and paste it into a file and run it.)
void shuffle(int a, int *b, int &c) { int temp = a; a = *b; b = &temp; cout << a << ',' << b << ',' << c << endl; c = a + *b + temp; } int main() { int a = 1; int b = 2; int c = 3; shuffle(a, &b, c); cout << a << ',' << b << ',' << c << endl; }