-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathP152.java
44 lines (35 loc) · 1.03 KB
/
P152.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package p100_199;
import java.util.Scanner;
//accepted
public class P152 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
short n = sc.nextShort();
while (n!=0){
int [] arr = new int[n];
int contador=0;
int max=0;
int valorMax=Integer.MIN_VALUE;
for (int i = 0; i < arr.length; i++) {
arr[i]=sc.nextInt();
}
for (int i = 0; i < arr.length; i++) {
int valor=arr[i];
if (valor==-1) continue;
for (int j = i; j < arr.length; j++) {
if (arr[j]==valor){
arr[j]=-1;
contador++;
}
}
if (contador>max){
max = contador;
valorMax=valor;
}
contador=0;
}
System.out.println(valorMax);
n= sc.nextShort();
}
}
}