-
Notifications
You must be signed in to change notification settings - Fork 19
Expand file tree
/
Copy pathbeekeeper.java
More file actions
55 lines (44 loc) · 944 Bytes
/
beekeeper.java
File metadata and controls
55 lines (44 loc) · 944 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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
import java.util.Scanner;
public class beekeeper {
public static int count(String str) {
int sum = 0;
for (int i = 0; i < str.length() - 1; i++)
{
if (str.substring(i , i + 2).equals("aa"))
sum++;
if (str.substring(i , i + 2).equals("ee"))
sum++;
if (str.substring(i , i + 2).equals("ii"))
sum++;
if (str.substring(i , i + 2).equals("oo"))
sum++;
if (str.substring(i , i + 2).equals("uu"))
sum++;
if (str.substring(i , i + 2).equals("yy"))
sum++;
}
return sum;
}
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
while (true)
{
int n = scan.nextInt();
if (n == 0)
break;
String[] words = new String[n];
for (int i = 0; i < n; i++)
words[i] = scan.next();
int max = -1;
String fav = "";
for (int i = 0; i < n; i++)
if (count(words[i]) > max)
{
fav = words[i];
max = count(words[i]);
}
System.out.println(fav);
}
scan.close();
}
}