-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMain.java
More file actions
29 lines (21 loc) · 847 Bytes
/
Copy pathMain.java
File metadata and controls
29 lines (21 loc) · 847 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
System.out.println("Digite o numero de discos da torre de hanoi a ser resolvida: ");
Scanner input = new Scanner(System.in);
int qtd = input.nextInt();
moveTower(qtd, "Torre1", "Torre2", "Torre3");
System.out.println("Terminou");
}
public static void moveDisk(String fromPole, String toPole){
//System.out.println("Movendo disco de "+fromPole+" para "+toPole);
}
public static void moveTower(int height, String fromPole, String toPole, String withPole){
if(height >= 1){
moveTower(height - 1, fromPole, withPole, toPole);
moveDisk(fromPole, toPole);
moveTower(height - 1, withPole, toPole, fromPole);
}
else return;
}
}