import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;
/**
* Created by mac on 2018/12/1.
*/
public class Main {
public static void main(String[]args){
Scanner input = new Scanner(System.in);
int N = input.nextInt();
String key = "";
while(N != 0){
//键值对首先选择运用map函数储存
Map<String,Integer> map = new HashMap<>();
for (int i = 0; i < N;i++){
String color = input.next();
//看map里面有没有color,没有则添加,有则让value++ 并覆盖
if (map.containsKey(color)){
int time = map.get(color)+1;
map.put(color,time);
}else
map.put(color,1);
int value = 0;
//寻找出现最多次的颜色
for (Map.Entry<String,Integer> entry:map.entrySet()){
if (entry.getValue() > value){
key = entry.getKey();
value = entry.getValue();
}
}
}
System.out.println(key);
N = input.nextInt();
}
input.close();
}
}
网友评论