求一维数组 a 中所有元素的平均值。 例如,当一维数组 a 中的元素为: 10,4,2,7,3,12,5,34,5,9 程序的输出应为: The aver is: 9.10 。 #include
#include
void main() { int a[10]={10,4,2,7,3,12,5,34,5,9},i; double aver,s; s = a[0]; /************found************/ for ( i=0; i<10; i++) /************found************/ s = s + i; aver = s / i; printf("The aver is: %.2f\n", aver); }