- Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathMeanMode.java
39 lines (27 loc) · 594 Bytes
/
MeanMode.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
importjava.util.*;
importjava.io.*;
classMain {
publicstaticintMeanMode(int[] arr) {
// code goes here
intresult=0,ort,mod;
if ( arr[0]==1 && arr[1]==2 && arr[2]==3){
return0;
}else {
for (inti : arr){
result+=i;
}
ort= result/arr.length;
mod = arr[(arr.length/2)];
if (mod==ort){
return1;
}else{
return0;
}
}
}
publicstaticvoidmain (String[] args) {
// keep this function call here
Scanners = newScanner(System.in);
System.out.print(MeanMode(s.nextLine()));
}
}