#include <iostream>
#include <cmath>
float Xb_2() // 求Xb的平方
{
float temp = 0.0;
std::cout << "enter B class." << std::endl;
scanf("%f",&temp);
return (temp * temp);
}
float Xa_2() // 求Xa的平方
{
float temp = 0.0;
float lenghNumber[6] = {0.0};
for(int i = 0; i < 6; i++)
{
std::cout << "enter data " << (i + 1) << std::endl;
scanf("%f",&lenghNumber[i]);
}
float average = 0.0;
std::cout << "enter average." << std::endl;
scanf("%f", &average);
for(int i = 0; i < 6; i++)
{
temp += ((lenghNumber[i] - average) * (lenghNumber[i] - average));
}
return (temp / 30.0);
}
float sqrt_all() // 求不确定度
{
float temp = 0.0;
temp = sqrt(Xa_2() + Xb_2());
return (temp);
}
void disp() // 输出结果
{
std::cout << sqrt_all() << std::endl;
}
int main(int argc, char *argv[])
{
disp();
return (0);
}
计算不确定度的代码,老师再也不用担心我算错结果了= =DEBUG中……
最新推荐文章于 2023-10-23 18:26:51 发布