/** * 求数组中的最大值 * * @param a */ public double maxElement(double a[]) { double max = a[0]; for (int i = 0; i < a.length; i++) { if (a[i] > max) { max = a[i]; } } return max; } /** * 求数组中的平均值 * * @param a */ public double average(double a[]) { int len = a.length; double sum = 0.0; for (int i = 0; i < len; i++) { sum += a[i]; } return sum / len; } /** * 复制数组 * @param a */ public void copyArray(double a[]) { int len = a.length; double[] b = new double[len]; for (int i = 0; i < len; i++) { b[i] = a[i]; } } /** * 数组反转 * @param a */ public void reverse(double a[]){ int len = a.length; for(int i=0;i<len/2;i++){ double temp = a[i]; a[i] = a[len-1-i]; a[len-1-i] = temp; } }