-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBOJ-04446-ROT13.java
More file actions
55 lines (42 loc) · 1.57 KB
/
Copy pathBOJ-04446-ROT13.java
File metadata and controls
55 lines (42 loc) · 1.57 KB
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
// BOJ-04446 / ROT13
// devgeon, 2024.09.19, Java 11
// https://www.acmicpc.net/problem/4446
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
public class Main {
public static void main(String[] args) throws IOException {
final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
final BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
final String VOWELS = "UOEYIAUOE", CONSONANTS = "FMLRSTQJVPGWCDHNZXKBFMLRSTQJVP";
String input = "";
char ch = '0';
boolean isUpper = false, isVowel = false;
while ((input = br.readLine()) != null) {
for (int i = 0, idx = 0; i < input.length(); i++) {
ch = input.charAt(i);
if (!Character.isAlphabetic(ch)) {
bw.write(ch);
continue;
}
isUpper = Character.isUpperCase(ch);
ch = Character.toUpperCase(ch);
idx = VOWELS.indexOf(ch);
isVowel = true;
if (idx < 0) {
idx = CONSONANTS.indexOf(ch);
isVowel = false;
}
ch = isVowel ? VOWELS.charAt(idx + 3) : CONSONANTS.charAt(idx + 10);
ch = isUpper ? ch : Character.toLowerCase(ch);
bw.write(ch);
}
bw.write('\n');
}
bw.flush();
br.close();
bw.close();
}
}