有几个数,把N的定义改一下就行。现在是10
# include <stdio.h>
# include <math.h>
#define N 10
main()
{
double a[N];
double count,pingjun, fangcha,biaozhuncha;
int i;
printf("请输入%d个数", N);
for (i = 0; i < N; i++)
{
scanf("%lf",&a[i]);
}
/* 求平均数 */
count = 0;
for (i = 0; i < N; i++)
{
count += a[i];
}
pingjun = count / N;
/* 求方差 */
count = 0;
for (i = 0; i < N; i++)
{
count += pow((a[i]- pingjun), 2);
}
fangcha = count / N;
/* 求标准差 */
biaozhuncha = sqrt(fangcha);
printf("这些数的平均数是%lf", pingjun);
printf("这些数的方差是%lf", fangcha);
printf("这些数的标准差是%lf", biaozhuncha);
}