Ayuda movimientos de las torres de hanoi

Alcar
27 de Abril del 2008
Hola, necesito un el codigo fuente de un programa que imprima las soluciones o movimientos de las torres de hanoi. estoy empezando a aprender C++ en console y me pidieron realizarla de esta manera:
Que sea para n discos y que imprima los movimientos de esta manera:

movimientos / Palo 1 / palo 2 / palo 3
1 123 0 0
2 23 1 0
3 3 1 2
4 3 0 12
...
0 0 123
asi de esta manera...
de antemano muchas gracias por su ayuda.
suerte

Alcar
27 de Abril del 2008
Edito la respuesta de los movimientos a impirmir
movimientos / Palo 1 / palo 2 / palo 3
1/ 123/ 0/ 0
2/ 23/ 1/ 0
3/ 3/ 1/ 2
4/ 3/ 0/ 12
...
n/0/ 0/ 123

Porfavor es urgente muchas gracias

Noel Solw
27 de Abril del 2008
// program k7a13.CPP - page 127
// recursion : Hanoi Towers.
// c++ exercices book - dr. gershon kagan (first edition : 2001)
// arie wlos - 28/10/2001
// written in Borland CPP ver 3.1

#include <conio.h>
#include <iostream.h>
#include <iomanip.h>

const char *col[] = {"column a","column b","column c"};
int counter;

unsigned int GetNum(char *x)
{
unsigned int num;
cout << endl;
cout << setw(17) << x << " = ";
cin >> num;
cout << endl;
return num;
} // GET NUM

void Move(int n,int source,int target)
{
cout << "[" << setw(2) << counter ++
<< "] move disk number " << n << " from " << col[source] << " to "
<< col[target] << endl;
} // MOVE

void Hanoi(int n,int source,int auxiliar, int target)
{
if(n == 1)
Move(n,source,target);
else
{
Hanoi(n-1,source,target,auxiliar);
Move(n,source,target);
Hanoi(n-1,auxiliar,source,target);
}
} // HANOI

void main()
{
clrscr();
cout << "recursion : Hanoi Towers."
<< endl << endl;
for(;;)
{
int n = GetNum("level");
if(n <= 0)
break;
counter = 1;
Hanoi(n,0,1,2);
}
cout << endl << "end of program - good bye ! ! !" << endl;
getch();
} // MAIN

/*
recursion : Hanoi Towers.

level = 1

[ 1] move disk number 1 from column a to column c

level = 2

[ 1] move disk number 1 from column a to column b
[ 2] move disk number 2 from column a to column c
[ 3] move disk number 1 from column b to column c

level = 3

[ 1] move disk number 1 from column a to column c
[ 2] move disk number 2 from column a to column b
[ 3] move disk number 1 from column c to column b
[ 4] move disk number 3 from column a to column c
[ 5] move disk number 1 from column b to column a
[ 6] move disk number 2 from column b to column c
[ 7] move disk number 1 from column a to column c

level = 4

[ 1] move disk number 1 from column a to column b
[ 2] move disk number 2 from column a to column c
[ 3] move disk number 1 from column b to column c
[ 4] move disk number 3 from column a to column b
[ 5] move disk number 1 from column c to column a
[ 6] move disk number 2 from column c to column b
[ 7] move disk number 1 from column a to column b
[ 8] move disk number 4 from column a to column c
[ 9] move disk number 1 from column b to column c
[10] move disk number 2 from column b to column a
[11] move disk number 1 from column c to column a
[12] move disk number 3 from column b to column c
[13] move disk number 1 from column a to column b
[14] move disk number 2 from column a to column c
[15] move disk number 1 from column b to column c

level = 0

end of program - good bye ! ! !
*/