//键盘输入10个数,求他们的方差
#include<stdio.h>
#include<math.h>
int main() {
int i ,arr[20],sum=0;
double average = 0, average2=0, s = 0;
printf("请输入10个数");
for (i = 0; i < 10; i++) {
scanf("%d", &arr[i]);
sum += arr[i];
}
average = sum / 10; //求十个数的平均数
for (i = 0; i < 10; i++) {
average2 += (arr[i] - average) * (arr[i] - average); //每个数与平均值相减,的平方值,的和
}
s = average2 / 10; //再次获取平均数
s = sqrt(average); //根据公式 需要开方
printf("%.2f",s);
return 0;
}