今天做了一个简单题
import java.util.*; public class Solution { /** * * @param arr int整型一维数组 * @return int整型 */ public int Answerofjudge (int[] arr) { Arrays.sort(arr); int len = arr.length; double min = 0.00; double avr = 0.00; double num = 0.00; if(len%2==0){ min = (double) (arr[len/2-1] + arr[len/2])/2; } else { min = (double) arr[len/2]; } for(int i=0; i < len; i++){ num = num+arr[i]; } avr = (double) num/len; if(avr > min){ return -1; } else if (avr < min){ return 1; } else { return 0; } } }