public class Test3{
public static void main(String[] args) {
Scanner sc=new
Scanner(System.in
);
while (sc.hasNextLine()){
String s=sc.
nextLine();
String [] str=s.
split(" ");
Integer [] arr= new Integer[str.length]
;
for(int i=0
;i<str.length
;i++){
arr[i]=Integer.
parseInt(str[i]
);//将字符串转化为整数
}
System.out.
println(number(arr,arr.length
));
}
}
public static int number(Integer[] arr,int m){
int n=m/2
;
int s=0
;
for(int i=0
;i<m
;i++){
int count=0
;
for(int j=0
;j<m
;j++){
if(arr[i]==arr[j]){
count++
;
}
}
if(count>=n){
s=arr[i]
;
break
;
}
}
return s
;
}
}
转载请注明原文地址:https://ipadbbs.8miu.com/read-1812.html