FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
programming/recursion/java/tower_of_hanoi.java at master · Scarlet-Coder/programming · GitHub
Scarlet-Coder
/
programming
Public
forked from
hacktoberfest17/programming
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
programming
/
recursion
/
java
/
tower_of_hanoi.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
16 lines (15 loc) · 528 Bytes
Breadcrumbs
programming
/
recursion
/
java
/
tower_of_hanoi.java
Copy path
File metadata and controls
16 lines (15 loc) · 528 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
public
class
tower_of_hanoi
{
public
static
void
TowerOfHanoi
(
int
n
,
char
from_rod
,
char
to_rod
,
char
aux_rod
) {
if
(
n
==
1
)
System
.
out
.
println
(
from_rod
+
" --> "
+
to_rod
);
else
{
TowerOfHanoi
(
n
-
1
,
from_rod
,
aux_rod
,
to_rod
);
System
.
out
.
println
(
from_rod
+
" --> "
+
to_rod
);
TowerOfHanoi
(
n
-
1
,
aux_rod
,
to_rod
,
from_rod
);
}
}
public
static
void
main
(
String
[]
args
) {
int
blocks
=
5
;
// Number of blocks in the tower
TowerOfHanoi
(
blocks
,
'A'
,
'C'
,
'B'
);
// Moving all blocks from A to C
}
}
Back
|
FazBrowse Home
|
New Git URL