根据教师的花名册,找到出勤最多的人。
输入格式:
出勤记录单行给出,数据直接使用空格分割。
输出格式:
单行输出(若有多人,人名直接使用空格分割,结尾处没有空格)。
输入样例:
在这里给出一组输入。例如:
zs ls ww ml zs ls ml zs ww
结尾无空行
输出样例:
在这里给出相应的输出。例如:
zs
结尾无空行
public static void main(String[] args) {
ArrayList<String> List = new ArrayList<>();
Scanner scan = new Scanner(System.in);
int max=0;
String s="";
while(scan.hasNext())
{
String a=scan.next();
List.add(a);
}
for(int i=0;i<List.size();i++)
{
int m=0;
for(int k=0;k<List.size();k++)
{
if(List.get(k).equals(List.get(i)))
{
m++;
if(max<m)
{
max=m;
s=List.get(i);
}
}
}
}
System.out.println(s);
}
}