解题思路:
注意事项:
参考代码:
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner=new Scanner(System.in);
int n=scanner.nextInt();
int[] a=new int[n];
int[] b=new int[n];
for (int i = 0; i < a.length; i++) {
a[i]=scanner.nextInt();
}
for (int i = 0; i < a.length; i++) {
int sum=0;
for (int j = 0; j < a.length; j++) {
if (a[i]==a[j]) {
sum++;
}
}
b[i]=sum;
}
int num=0;
int m=0;
for (int i = 0; i < b.length; i++) {
if (b[i]>num) {
num=b[i];
m=i;
}
}
System.out.println(a[m+1]);
}
}
0.0分
1 人评分