在考生文件夾下,給定程序MODI.C的功能是:
求一維數(shù)組a中所有元素的平均值,結(jié)果保留兩位小數(shù)。
例如,當一維數(shù)組a中的元素為:10,4,2,7,3,12,5,34,5,9
程序的輸出應(yīng)為:The aver is: 9.10 。
#include
#include
void main()
{
int a[10]={10,4,2,7,3,12,5,34,5,9},i;
float aver,s; |
int aver,s;
/************found************/
s=a[0]; |
for ( i=1; i<10; i++)
s += a[i];
aver = s / i;
printf("The aver is: %.2f\n", aver);
}
![]() | ![]() .. 定價:¥225 優(yōu)惠價:¥213 更多書籍 |
![]() | ![]() .. 定價:¥133 優(yōu)惠價:¥133.0 更多書籍 |