6
#include <stdio.h>
#include <stdlib.h>
void solve(int QTD_DISCOS, int origem, int destino, int temp)
{
static int rank = 0;
if (QTD_DISCOS > 0)
{
solve(QTD_DISCOS-1, origem, temp, destino);
printf("%4d ) %c --> %c\n", ++rank, '@' + origem, '@' + destino);
solve(QTD_DISCOS-1, temp, destino, origem);
}
}
int main()
{
int d;
printf("Digite o numero de discos da Torre de Hanoi: \n");
scanf("%d", &d);
printf("A solucao de Hanoi eh: \n");
solve(d, 1, 3, 2);
return 0;
}
I think the direct answer to the question should come at the beginning. All its editions gave a deeper answer, but ended up distancing the direct content from the doubt of the focus.
– Jefferson Quesado