-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path3-2-2.java
More file actions
31 lines (30 loc) · 848 Bytes
/
3-2-2.java
File metadata and controls
31 lines (30 loc) · 848 Bytes
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
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
String S = scanner.next();
String T = "";
int i = 0;
while (i < S.length()) {
if (S.charAt(i) != 'a' && S.charAt(i) != 'A') {
T = T + S.charAt(i);
i++;
continue;
}
int j = i + 1;
while (j < S.length()) {
if (S.charAt(j) != 'a' && S.charAt(j) != 'A') {
break;
}
j++;
}
if (j - i == 1) {
T = T + S.charAt(i);
} else {
T = T + 'a';
}
i = j;
}
System.out.println(T);
}
}