中位数

public static void main(String[] args) {
    int[] num = {20,21,23, 23};
    int[] num2 = {25,  29,32,33};
    int[] concat = concat(num, num2);
    Arrays.sort(concat);
    int i1 = concat[concat.length / 2];
    int i2 = concat[concat.length / 2-1];
    int c=(i1+i2)/2;
    System.out.println(c);
}
public static  int[] concat(int[] first, int[] second) {
    int[] result = Arrays.copyOf(first, first.length + second.length);
    System.arraycopy(second, 0, result, first.length, second.length);
    return result;
}

你可能感兴趣的:(java)