public class Mode {
public int mode(int []arr,int length){
int temp,temp1=0,res = arr[0];
for(int i = 0;i<length-1;i++){
temp = 0;
for(int j = i+1;j<length;j++){
if(arr[i] == arr[j]){
for(int l = j;l<length-1;l++){
arr[l] = arr[l+1];
}
temp++;
j--;
length--;
}
}
if(temp1<temp){
temp1 = temp;
res = arr[i];
}
}
return res;
}
}
众数,java
最新推荐文章于 2022-08-01 09:10:38 发布