求一维数组 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; /************found************/ int aver,s; /************found************/ s = 0; for ( i=1; i<10; i++) s += a[i]; aver = s / i; printf("The aver is: %.2f\n", aver); }