-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy paththebackslashproblem.java
32 lines (29 loc) · 1.03 KB
/
thebackslashproblem.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
import java.io.*;
import java.util.*;
public class thebackslashproblem {
public static void main(String[] args) throws Exception {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
String line = "";
while((line = in.readLine()) != null) {
int loi = Integer.parseInt(line);
line = in.readLine();
for(int i = 0; i < loi; i++) {
String x = "";
for(int j = 0; j < line.length(); j++) {
if(!special(line.charAt(j)))
x += line.substring(j, j + 1);
else {
x += "\\" + line.substring(j, j + 1);
}
}
line = x;
}
out.println(line);
}
out.close();
}
private static boolean special(char c) {
return c >= '!' && c <= '*' || c >= '[' && c <= ']';
}
}