package Question_one;
/*
* 出现次数最多的数
*/
import java.util.*;
public class Question_2013_12 {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int N = scanner.nextInt();
int []arry = new int[N];
int []count = new int[N];
for(int i = 0;i <N;i++) {
arry[i] = scanner.nextInt();
count[i]=1;
}
for(int i = 0;i<N;i++) {
for(int j = i+1; j <N;j++) {
if(arry[j] == arry[i])
count[i]++;
}
}
int max=0;
int p = 0 ;
int m;
for(int i = 0 ;i <N;i++) {
if(count[i]>max) {
max = count[i];
p = i;
}else if(count[i] == max) {
if(arry[p]>arry[i])
p=i;
}
}
System.out.println(arry[p]);
}
}
不足之处,欢迎指正!