Torres de Hanoi
necesito hacer el codigo en java de las torres de hanoi o encontrarlo, espero y lo tengan a sus manos. me harian mucha ayuda, thanks
Podrias al menos poner a funcionar un poquito tu mente en programar el algoritmo recursivo tu mismo????
Ose digo no ????
Saludos!!!!
Ose digo no ????
Saludos!!!!
Hola, Estoy super de acurdo con neos, pon a trabajar ese cerebrito y cuando te atores en algo en tonces si pregunta en los foros, no antes (no te acostubres que los demas resuelvan tu trabajo)
Saludos
Saludos
A ver si te sirve esto:
public class Hanoi {
// move n smallest discs from one pole to another, using the temp pole
public static void hanoi(int n, String from, String temp, String to) {
if (n == 0) return;
hanoi(n-1, from, to, temp);
System.out.println("Move disc " + n + " from " + from + " to " + to);
hanoi(n-1, temp, from, to);
}
public static void main(String[] args) {
int N = Integer.parseInt(args[0]);
hanoi(N, "A", "B", "C");
}
}
public class Hanoi {
// move n smallest discs from one pole to another, using the temp pole
public static void hanoi(int n, String from, String temp, String to) {
if (n == 0) return;
hanoi(n-1, from, to, temp);
System.out.println("Move disc " + n + " from " + from + " to " + to);
hanoi(n-1, temp, from, to);
}
public static void main(String[] args) {
int N = Integer.parseInt(args[0]);
hanoi(N, "A", "B", "C");
}
}