java一位数组求平均值,小数
package com.c2;
//注意数据类型,float public class Col {//
public static void main(String[] args) { float m[] = new float[4]; float sum = 0; m[0] = 3; m[1] = 1; m[2] = 4; for (int i = 0; i < m.length; i++) { sum += m[i]; // 求一维数组的平均值 } System.out.println(sum / 3); } }