求简单C语言编程,标准偏差和最大值
答案:1 悬赏:80 手机版
解决时间 2021-04-13 14:35
- 提问者网友:遮云壑
- 2021-04-12 15:04
求简单C语言编程,标准偏差和最大值
最佳答案
- 五星知识达人网友:你可爱的野爹
- 2021-04-12 15:36
#include
#include
#include
float Average(float data[], int number);
float Maxium(float data[], int number);
float Bias(float data[], int number);
int main()
{
int number;
float data[10] = {0};
printf("please input the numbers of the data
");
scanf("%d", &number);
for (int i = 0; i < number; i++)
scanf("%f", &data[i]);
printf("%f", Bias(data, number));
return 0;
}
float Average(float data[], int number)
{
float sum = 0.0;
for(int i = 0; i < number; i++)
{
sum += data[i];
}
return sum / number;
}
float Maxium(float data[], int number)
{
float max = data[0];
for (int i = 1; i < number; i++)
{
if (max < data[i])
{
max = data[i];
}
}
return max;
}
float Bias(float data[], int number)
{
float temp = 0.0f;
float average = Average(data, number);
for (int i = 0; i < number; i++)
{
temp += powf(data[i] - average, 2);
}
return sqrtf((1.0 / (number - 1)) * temp);
}
#include
#include
float Average(float data[], int number);
float Maxium(float data[], int number);
float Bias(float data[], int number);
int main()
{
int number;
float data[10] = {0};
printf("please input the numbers of the data
");
scanf("%d", &number);
for (int i = 0; i < number; i++)
scanf("%f", &data[i]);
printf("%f", Bias(data, number));
return 0;
}
float Average(float data[], int number)
{
float sum = 0.0;
for(int i = 0; i < number; i++)
{
sum += data[i];
}
return sum / number;
}
float Maxium(float data[], int number)
{
float max = data[0];
for (int i = 1; i < number; i++)
{
if (max < data[i])
{
max = data[i];
}
}
return max;
}
float Bias(float data[], int number)
{
float temp = 0.0f;
float average = Average(data, number);
for (int i = 0; i < number; i++)
{
temp += powf(data[i] - average, 2);
}
return sqrtf((1.0 / (number - 1)) * temp);
}
我要举报
如以上问答信息为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
大家都在看
推荐资讯