/****************************************************************************** Welcome to GDB Online. GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl, C#, OCaml, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog. Code, Compile, Run and Debug online from anywhere in world. *******************************************************************************/ #include using namespace std; void hanoiRec(uint n, char origen, char intermedio, char destino) { if (n == 1) { printf("Mover disco %d de %c a %c\n", 1, origen, destino); } else { hanoiRec(n - 1, origen, destino, intermedio); printf("Mover disco %d de %c a %c\n", n, origen, destino); hanoiRec(n - 1, intermedio, origen, destino); } } void hanoi(uint n) { hanoiRec(n, 'A', 'B', 'C'); } int main() { uint n = 3; hanoi(n); return 0; }