-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathWERTYU.java
35 lines (29 loc) · 1.07 KB
/
WERTYU.java
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
32
33
34
35
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class WERTYU {
private static final BufferedReader reader = new BufferedReader(
new InputStreamReader(System.in));
private final static String KEYS = "`1234567890-=QWERTYUIOP[]\\ASDFGHJKL;'ZXCVBNM,./";
private final static int[] map = new int[256];
static {
for (int i = 0; i < KEYS.length(); ++i) {
map[KEYS.charAt(i)] = i;
}
}
private static String shift(String currentLine) {
StringBuilder output = new StringBuilder();
for (int i = 0; i < currentLine.length(); ++i) {
output.append(map[currentLine.charAt(i)] != 0
? KEYS.charAt(map[currentLine.charAt(i)] - 1)
: currentLine.charAt(i));
}
return output.toString();
}
public static void main(String[] args) throws IOException {
String currentLine;
while ((currentLine = reader.readLine()) != null) {
System.out.println(shift(currentLine));
}
}
}