-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathQ5.java
More file actions
38 lines (28 loc) · 788 Bytes
/
Q5.java
File metadata and controls
38 lines (28 loc) · 788 Bytes
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
import java.util.*;
class Q5 {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int size;
System.out.println("Enter Size: ");
size = sc.nextInt();
int arr[] = new int[size];
for (int i = 0; i < size; i++) {
arr[i]=sc.nextInt();
}
System.out.println("Number : Occurance");
for (int i = 0; i < size; i++) {
int count = 1;
if (arr[i]!=-1) {
for (int j = i+1; j < size; j++) {
if(arr[i]==arr[j])
{
count++;
arr[j]=-1;
}
}
System.out.println(arr[i] + " : " + count);
}
}
sc.close();
}
}