-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy path1171.java
41 lines (37 loc) · 1.29 KB
/
1171.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
import java.io.IOException;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
while (sc.hasNextInt()) {
int n = 0, num = 0, cont = 0, aux = 0, cont2 = 0;
n = sc.nextInt();
int[] vet = new int[n];
for (int i = 0; i < n; i++) {
vet[i] = sc.nextInt();
}
for (int i = 0; i < vet.length; i++) {
for (int j = 0; j < vet.length - 1; j++) {
if (vet[j] > vet[j + 1]) {
aux = vet[j];
vet[j] = vet[j + 1];
vet[j + 1] = aux;
}
}
}
for (int i = 0; i < vet.length; i++) {
cont = 0;
num = vet[i];
for (int j = 0; j < vet.length; j++) {
if (vet[i] == vet[j] && vet[i] != 0 && vet[j] != 0 && vet[j] != cont2) {
cont++;
}
}
cont2 = vet[i];
if (cont != 0 && vet[i] != 0) {
System.out.println(num + " aparece " + cont + " vez(es)");
}
}
}
}
}