-
Notifications
You must be signed in to change notification settings - Fork 0
/
rudolfugly.java
38 lines (34 loc) · 1.24 KB
/
rudolfugly.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
36
37
38
import java.util.*;
public class rudolfugly {
public static void main(String[] args) {
Scanner kbd = new Scanner(System.in);
int intput = kbd.nextInt(), length, res = 0;
kbd.nextLine();
String[] letras;
int[] reses = new int[intput];
for(int i = 0; i < intput; i++) {
length = kbd.nextInt();
kbd.nextLine();
String input = kbd.next();
kbd.nextLine();
letras = input.split("");
boolean contains = input.contains("pie") || input.contains("map");
while(contains) {
contains = input.contains("pie") || input.contains("map");
for(int j = 0; j < length; j++) {
String letra = letras[j];
if(letra.equals("i") || letra.equals("e") || letra.equals("a")) {
letras[j] = "";
res++;
input="";
for(int k = 0; k < letras.length; k++) {
input += letras[k];
}
break;
}
}
}
reses[i] = res;
}
}
}