This commit is contained in:
2022-04-13 20:49:31 +02:00
parent 99762353e9
commit fb187effcc
20 changed files with 587 additions and 6 deletions

View File

@@ -0,0 +1,16 @@
package lab14_recursivity;
public class HanoiTower {
public static void main(String[] args) {
hanoi(3, 'a', 'b', 'c');
}
public static void hanoi(int n, char start, char aux, char end){
if (n != 0){
hanoi(n-1, start, end, aux);
System.out.println("Move disk " + n + " from " + start + "->" + end);
hanoi(n-1, aux, start, end);
}
}
}