Created
March 22, 2016 03:06
-
-
Save alvareztech/7a8144e98830b208e02e to your computer and use it in GitHub Desktop.
Tower of Hanoi recursive algorithm
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static void algoritmoHanoi(int n, int origen, int temporal, int destino) { | |
| if (n == 0) { | |
| return; | |
| } | |
| algoritmoHanoi(n - 1, origen, destino, temporal); | |
| System.out.println("Mover " + n + " de la torre " + origen + " a la torre " + destino + "."); | |
| algoritmoHanoi(n - 1, temporal, origen, destino); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment