blob: 05ebce2e862049c7e5d2e035bbe04149f4049463 (
plain)
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
30
31
|
//
// See ../README.md
//
//
// Run as: ln ch-2.java ch2.java; javac ch2.java; java ch2 < input-file
//
import java.util.*;
public class ch2 {
static void steps (int x, int y, String path) {
if (x == 0 && y == 0) {
System . out . println (path);
}
if (x > 0) {
steps (x - 1, y + 1, path + "L");
steps (x - 1, y, path + "R");
}
if (y > 0) {
steps (x, y - 1, path + "H");
}
}
public static void main (String [] args) {
Scanner scanner = new Scanner (System . in);
int size = scanner . nextInt ();
steps (size, 0, "");
}
}
|