Hi all I need to write a recursive function that displays every permitation of NxN numbers this example uses 3x3 and will display
0 1 0
1 1 0
2 1 0
0 2 0
1 2 0
2 2 0
0 0 1
1 0 1
2 0 1
0 1 1
1 1 1
2 1 1
0 2 1
1 2 1
2 2 1
0 0 2
1 0 2
2 0 2
0 1 2
1 1 2
2 1 2
0 2 2
1 2 2
2 2 2
using:
for (int c=0; c<3 ; c++)
for (int b=0; b<3 ; b++)
for(int a = 0; a<3; a++)
cout <<a<<" "<<b<<" "<<c<<endl;
I would like to rewrite this as a recursive function for example
displayNumbers(5,3)
which would display each combination for 5 colums of 0 to 3.
I just can't seem to figure out how to make this into a recursive function.
I would really apreciate any help as you guys seem really knolagable.
Thanks in advance,
dubery.