900字范文,内容丰富有趣,生活中的好帮手!
900字范文 > 大学物理旋转液体测重力加速度数据处理

大学物理旋转液体测重力加速度数据处理

时间:2020-02-12 14:38:45

相关推荐

大学物理旋转液体测重力加速度数据处理

大学物理旋转液体测重力加速度的数据处理C++实现

注意:不控制有效位数,请自行判断保留位数

#include <iostream>#include<cmath>using namespace std;#define pi 3.1415926535//luosansuifloat* printin(const char str[], float arr[]) {char judge;while (1) {cout << "输入" << str << ",共六个数据" << endl;for (int i = 0; i < 6; i++) {cin >> arr[i];}cin.ignore(std::numeric_limits< streamsize >::max(), '\n');cout << "输入数据: ";for (int i = 0; i < 6; i++) {cout << arr[i] << " ";}cout << endl << "继续请按 N,重新输入请按 B" << endl;cin >> judge;cin.clear();cin.ignore(std::numeric_limits< streamsize >::max(), '\n');if (judge == 'N' || judge == 'n') {break;}else if (judge == 'B' || judge == 'b') {system("cls");cout << "正在重新输入。。。" << endl;}else {cout << "默认继续输入。。。" << endl;break;}}return arr;}void wSquare(float* p) {double a;for (int i = 0; i < 6; i++){a = (2.0 * pi) / (p[i] / 20.0);a = pow(a, 2);printf("w^2 = %.2f\n", a);}}double ave(float* pH, float* ph0) {double a = 0.0;double b = 0.0;double c = 0.0;for (int i = 0; i < 6; i++) {a += pH[i];}a = a / 6.0;printf("H的平均值为: %.2f\n", a);for (int i = 0; i < 6; i++) {b += ph0[i];}b = b / 6.0;printf("h0的平均值为: %.2f\n", b);c = a - b;return c;}void tan28(double py, float* px) {double a,b;for (int i = 0; i < 6; i++){cout << "第" << i + 1 << "组数据 ";a = px[i] / py;printf("tan28 = %.10f ", a);a = atan(a) / 2.0;b = a / (pi / 180.0);printf("8 = %.10f 度 ", b);a = tan(a);printf("tan8 = %.10f\n", a);}}void result(float* pl, float* pcolumn_20T, double y, float* x) {double r2 = 0.0;double x0, w, tan8, result1;for (int i = 0; i < 6; i++) {r2 += pl[i];}r2 = r2 / 6.0;printf("2R的平均值为: %.2fcm\n", r2);x0 = r2 / 2.0 / 100.0 / sqrt(2);//x0for (int i = 0; i < 6; i++){cout << "第" << i + 1 << "组数据 ";w = (2.0 * pi) / (pcolumn_20T[i] / 20.0);w = pow(w, 2);//w^2tan8 = x[i] / y;tan8 = atan(tan8) / 2.0;tan8 = tan(tan8);//tan8result1 = w * x0 / tan8;printf("重力加速度 = %.2f\n", result1);}}int main(){float l[6], h0[6], H[6], columu_20T[6], x1[6];float* pl = printin("2R", l);float* ph0 = printin("h0", h0);float* pH = printin("H", H);float* pcolumn_20T = printin("不同电压下的20T", columu_20T);float* px1 = printin("x1", x1);wSquare(pcolumn_20T);double aveg = ave(pH, ph0);tan28(aveg, px1);result(pl, pcolumn_20T, aveg, px1);system("pause");return 0;}

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。