We need to write a function of the following form: the input is an array arr , the number n and the function foo . It is necessary that the arr.size() ^ n times be performed on each of the elements of the arr array, i.e. need n nested loops. It is possible to make one cycle from 1 arr.size() ^ n , but this number easily overflows.
For example, when n = 3 function should degenerate into the following:
for (int i1 = 0; i1 < arr.size(); ++i1) for (int i2 = 0; i2 < arr.size(); ++i2) for (int i3 = 0; i3 < arr.size(); ++i3) foo(arr[i3]);
int * intwill fit into along long. - jfs