-
Notifications
You must be signed in to change notification settings - Fork 0
/
LE_11_1_2023.java
45 lines (35 loc) · 1.05 KB
/
LE_11_1_2023.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
45
package Assignments;
import java.util.Dictionary;
import java.util.Hashtable;
import java.util.Scanner;
public class LE_11_1_2023 {
public static void main(String ... a){
Scanner in = new Scanner(System.in);
int n;
System.out.print("Enter the no.of Elements: ");
n = in.nextInt();
int[] arr = new int[n];
System.out.println("Enter the Elements: ");
for(int i=0; i<n; i++)
{
arr[i]=in.nextInt();
}
int count = 0;
for(int i = 0 ; i < n; i++)
{
for(int j = 0; j < n; j++)
{
if(arr[i] == arr[j])
{
count = count + 1;
}
}
if(count > n / 2)
{
System.out.print(arr[i]);
break;
}
count = 0;
}
}
}