forked from yeicol/URI
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathURI1024Encryption.java
More file actions
46 lines (42 loc) · 1.33 KB
/
URI1024Encryption.java
File metadata and controls
46 lines (42 loc) · 1.33 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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
/**
* See
* <a href="https://www.urionlinejudge.com.br/judge/en/problems/view/1024">Encryption</a>
*
* @author Brian Yeicol Restrepo Tangarife
*/
public class URI1024Encryption {
static BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
static PrintWriter out = new PrintWriter(System.out);
public static void main(String[] args) throws IOException {
int N = Integer.parseInt(in.readLine()), half, length;
char[] M;
char temp;
while (N-- > 0) {
M = in.readLine().toCharArray();
length = M.length;
half = length / 2;
for (int i = 0; i < length; i++) {
if (Character.isLetter(M[i])) {
M[i] = (char) ((int) M[i] + 3);
}
}
for (int i = 0; i < half; i++) {
temp = M[i];
M[i] = M[M.length - i - 1];
M[M.length - i - 1] = temp;
}
for (int i = (half); i < length; ++i) {
M[i] = (char) ((int) M[i] - 1);
}
for (char Mi : M) {
out.print(Mi);
}
out.println();
}
out.close();
}
}