为了好处理数据,花了点时间写个几个小程序,做过实验思路还是挺容易懂的啦,注意一定要按照注释输入数据哦,或者根据数据的特点改一下条件语句也可以。
//自准直法测量三棱镜顶角
#include <cstdio>
#include <algorithm>
using namespace std;
double deal(double a, double b, double c, double d){
double x = a - c;
double y = b - d;
if(x < 0){
x = -x;
}
else{
x = 360 - x;
}
if(y < 0){
y = -y;
}
else{
y = 360 - y;
}
return 0.5 * (x + y);
}
int main()
{
//输入有顺序的...保证a[1]-a[3] && a[2]-a[4]为-120或者240左右
while(true){
double a[5][10], b[10], aver_b = 0;
double x, y;
for(int i=1; i<=4; i++){
for(int j=1; j<=5; j++){
scanf("%lf%lf", &x, &y);
a[i][j] = x + y/60;
}
}
for(int i=1; i<=5; i++){
b[i] = deal(a[1][i], a[2][i], a[3][i], a[4][i]);
printf("sita%d: %3.10lf\n", i, b[i]);
aver_b += b[i];
}
aver_b /= 5;
printf("average_sita: %3.10lf\n", aver_b);
printf("A: %3.10lf\n", 180 - aver_b);
double ua = 0, ub = 0, u = 0;
for(int i=1; i<=5; i++){
ua += (b[i] - aver_b) * (b[i] - aver_b);
}
ua = sqrt(ua/20);
ub = 1.0/60/sqrt(3);
printf("ua(sita): %3.10l