Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Recursividad: Hanoi
/* C program for Tower of Hanoi*/ /*Application of Recursive function*/ #include <stdio.h> void hanoifun(int n, char fr, char tr, char ar)//fr=from rod,tr =to rod, ar=aux rod { if (n == 1) { printf("\n Move disk 1 from rod %c to rod %c", fr, tr); return; } hanoifun(n-1, fr, ar, tr); printf("\n Move disk %d from rod %c to rod %c", n, fr, tr); hanoifun(n-1, ar, tr, fr); } int main() { int n = 4; // n immplies the number of discs hanoifun(n, 'A', 'C', 'B'); // A, B and C are the name of rod return 0; }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
Vectores: Burbuja
Recorrido matriz bidimensional y busqueda valor
Vectores: buscar valor en array
Día de la semana
Bucles: Triángulo de asteriscos lateral izquierdo
Vectores: bidimensionales con sizeof
Max number of a vector
Tree and binarySearch
Tablero de ajedrez
Paso parámetros a punteros
Please log in to post a comment.