import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
public class Main
{
public static void main(String[] args)
{
Scanner sc = new Scanner(System.in);
String line = sc.nextLine().trim();
while (!"0".equals(line))
{
int n = Integer.parseInt(line);
Map<String, Integer> map = new HashMap<String, Integer>(4 * n / 3);
for (int i = 0; i < n; i++)
{
String s = sc.nextLine().trim();
if (map.containsKey(s))
map.put(s, map.get(s) + 1);
else
map.put(s, 1);
}
int max = 0;
String color = null;
for (String s : map.keySet())
{
int temp = map.get(s);
if (temp > max)
{
color = s;
max = temp;
}
}
System.out.println(color);
line = sc.nextLine().trim();
}
}
}
ZOJ-2104
最新推荐文章于 2019-10-28 17:00:20 发布