style: format code (#4212)

close #4204
This commit is contained in:
acbin
2023-06-09 18:52:05 +08:00
committed by GitHub
parent ad03086f54
commit 00282efd8b
521 changed files with 5233 additions and 7309 deletions

View File

@ -4,20 +4,15 @@ import java.util.Scanner;
class TowerOfHanoi {
public static void shift(
int n,
String startPole,
String intermediatePole,
String endPole
) {
public static void shift(int n, String startPole, String intermediatePole, String endPole) {
// if n becomes zero the program returns thus ending the loop.
if (n != 0) {
// Shift function is called in recursion for swapping the n-1 disc from the startPole to the
// intermediatePole
// Shift function is called in recursion for swapping the n-1 disc from the startPole to
// the intermediatePole
shift(n - 1, startPole, endPole, intermediatePole);
System.out.format("Move %d from %s to %s\n", n, startPole, endPole); // Result Printing
// Shift function is called in recursion for swapping the n-1 disc from the intermediatePole
// to the endPole
// Shift function is called in recursion for swapping the n-1 disc from the
// intermediatePole to the endPole
shift(n - 1, intermediatePole, startPole, endPole);
}
}