计算一个整数数组的平均数
作者:互联网
public static void main(String[] args) {
// 计算平均数
int [] num = {1,2,3};
int snum = 0;
for (int i = 0; i < num.length; i++) {
snum += num[i];
}
System.out.println(snum);
double avg = snum/num.length;
System.out.println(avg);
}
标签:int,平均数,System,整数,length,num,数组,snum,avg 来源: https://www.cnblogs.com/dsds/p/14983685.html