package 作业;
import java.util.Scanner;
public class 第五次求数组的平均值 {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner sc = new Scanner(System.in);
int num = sc.nextInt();
int a[] = new int[num];
double b[] = new double[num];
for (int i = 0; i < num; i++) {
b[i] = sc.nextDouble();
}
System.out.println("everage= " + everage(b));
}
public static double everage(double[] c) {
double everage_n = 0;
for (int i = 0; i < 10; i++) {
everage_n = everage_n + c[i];
}
everage_n = everage_n / 10.0;
return everage_n;
}
public static double everage(int[] c) {
double everage_n = 0;
for (int i = 0; i < 10; i++) {
everage_n = everage_n + c[i];
}
everage_n = everage_n / 10.0;
return everage_n;
}
}
数组平均值
最新推荐文章于 2024-05-26 13:56:44 发布