标签:style class blog c http color
测量学平p135页,电脑算出来的与书上给出的数据分毫不差
今天测量学的实习数据处理
#include<iostream>
#include<cmath>
#include<iomanip>
#define
run
#define pi 3.1415926
using namespace std;
int
main()
{
int diao(long double max,int j,int n,int i,int U,int
B[100],long double d[100]);
int diao2(long double min,int j,int n,int
i,int U,int b[100],long double d[100]);
int
n,a[100],l,i,j,m,U,X,h,r[100],t[100],fd[100],ff[100],fm[100],vx[100],vy[100];
int
he=0,He=0,chazhi1,chazhi2;
static int b[100],B[100];
long
double
d[100],e[100],s=0,g=0,k,max,min,u[100],x[100],y[100],c[100],mima;
long
double
sum=0,Sum=0,f,K,yunxu,xh[100],yz[100];
do
{
cout<<"输入口令:"<<endl;
cin>>mima;
if(mima!=8105)
{
cout<<"口令错误!!!"<<endl;
}
}
while(mima!=8105);
cout<<"输入所测导线点的个数:";
cin>>n;
for(i=1;i<=n;i++)
{
cout<<"输入"<<i<<"观测角的度,分,秒与"<<i<<"导线边的距离:"<<endl;
cin>>a[i]>>B[i]>>c[i]>>d[i];
e[i]=a[i]+(long
double)B[i]/60+(long
double)c[i]/3600;
s=s+e[i];
g=g+d[i];
}
#ifdef
run
cout<<"距离和为"<<g<<"米"<<endl;
#endif
h=(s-(n-2)*180)*3600;
k=60*sqrt(n);
if(abs(h)>k)
{
cout<<"---------------------------------------------------------"<<"不合精度要求"<<endl;
}
else
{
cout<<"---------------------------------------------------------"<<"符合精度要求"<<endl;
l=-h/n;
if(l*n==-h)
{
cout<<"-----------------------------------------------------"<<"改正数为"<<l<<"秒"<<endl;
for(i=1;i<=n;i++)
{
e[i]=e[i]+(long
double)l/3600;
#ifdef
run
cout<<"改正角为"<<e[i]<<"度"<<endl;
#endif
}
}
else
if(l*n>-h)
{
for(i=1;i<=n;i++)
{
e[i]=e[i]+(long
double)l/3600;
}
m=l*n+h;
#ifdef
run
cout<<"------------------------------------------------------"<<"改正多了"<<m<<"秒";
#endif
for(i=1;i<=m;i++)
{
diao(max,j,n,i,U,B,d);
#ifdef
run
cout<<"-------------------------------------"<<"共需改正"<<m<<"个观测角"<<","<<i<<"号最长边为"<<"是"<<B[i]<<"号导线边"<<"--------"<<"距离为"<<d[B[i]]<<endl;
#endif
}
for(j=1;j<=l;j++)
{
if(B[j]==1)
{
if(d[2]<d[n])
{
#ifdef
run
cout<<"2号观测角-1秒"<<endl;
#endif
e[2]=e[2]-(long
double)1/3600;
}
else
{
#ifdef
run
cout<<"1号观测角-1秒"<<endl;
#endif
e[1]=e[1]-(long
double)1/3600;
}
}
if(B[j]==n)
{
if(d[1]<d[n-1])
{
#ifdef
run
cout<<"1号观测角-1秒"<<endl;
#endif
e[1]=e[1]-(long
double)1/3600;
}
else
{
#ifdef
run
cout<<n-1<<"号观测角-1秒"<<endl;
#endif
e[n-1]=e[n-1]-(long
double)1/3600;
}
}
for(X=2;X<n;X++)
{
if(B[j]==X)
{
if(d[X+1]<d[X-1])
{
#ifdef
run
cout<<X+1<<"号观测角-1秒"<<endl;
#endif
e[X+1]=e[X+1]-(long
double)1/3600;
//观测角的观测误差自动更正
}
else
{
#ifdef
run
cout<<X<<"号观测角-1秒"<<endl;
#endif
e[X]=e[X]-(long
double)1/3600;
}
}
}
}
}
///////////////////////////////////////////////////////////////////////////////////////////////
else
if(l*n<-h)
{
for(i=1;i<=n;i++)
{
e[i]=e[i]+(long
double)l/3600;
}
m=-h-l*n;
#ifdef
run
cout<<"--------------------------------------------------------------"<<"改正少了"<<m<<"秒"<<endl;
#endif
for(i=1;i<=m;i++)
{
diao2(min,j,n,i,U,b,d);
#ifdef
run
cout<<"-----------------------------------------------"<<"共需改正"<<m<<"个观测角"<<","<<i<<"号最短边为"<<"是"<<b[i]<<"号导线边"<<"--------"<<"距离为"<<d[b[i]]<<endl;
#endif
}
//////////////////////////////////////////////////////////
for(j=1;j<=l;j++)
{
if(b[j]==1)
{
if(d[2]<d[n])
{
#ifdef
run
cout<<"2号观测角+1秒"<<endl;
#endif
e[2]=e[2]+(long
double)1/3600;
}
else
{
#ifdef
run
cout<<"1号观测角+1秒"<<endl;
#endif
e[1]=e[1]+(long
double)1/3600;
}
}
if(b[j]==n)
{
if(d[1]<d[n-1])
{
#ifdef
run
cout<<"1号观测角+1秒"<<endl;
#endif
e[1]=e[1]+(long
double)1/3600;
}
else
{
#ifdef
run
cout<<n-1<<"号观测角+1秒"<<endl;
#endif
e[n-1]=e[n-1]+(long
double)1/3600;
}
}
for(X=2;X<n;X++)
{
if(b[j]==X)
{
if(d[X+1]<d[X-1])
{
#ifdef
run
cout<<X+1<<"号观测角+1秒"<<endl;
#endif
e[X+1]=e[X+1]+(long
double)1/3600;
}
else
{
#ifdef
run
cout<<X<<"号观测角+1秒"<<endl;
#endif
e[X]=e[X]+(long
double)1/3600;
}
}
}
}
}
for(i=1;i<=n;i++)
{
a[i]=e[i]/1;
b[i]=((e[i]-a[i])*60)/1;
c[i]=(((e[i]-a[i])*60-b[i])*60)/1;
#ifdef
run
cout<<"-----------------------------------------"<<"改正后的"<<i<<"观测角为"<<a[i]<<"°"<<b[i]<<"′"<<c[i]<<"″"<<endl;
#endif
}
cout<<"输入方位角1的度,分,秒"<<endl;
cin>>fd[1]>>ff[1]>>fm[1];
u[1]=fd[1]+(long
double)ff[1]/60+(long
double)fm[1]/3600;
for(i=2;i<=n;i++)
//////////////////////////////////////////////////////////////////////
{
u[i]=u[i-1]+e[i]-180;
u[3]=u[2]+e[3]+180;
}
for(i=1;i<=n;i++)
{
r[i]=u[i]/1;
t[i]=((u[i]-r[i])*60)/1;
y[i]=(((u[i]-r[i])*60-t[i])*60)/1;
#ifdef
run
cout<<"----------------------------------------"<<i<<"导线边的坐标方位角为:"<<r[i]<<"°"<<t[i]<<"′"<<y[i]<<"″"<<endl;
#endif
}
u[100]=u[n]+e[1]-180;
r[100]=u[100]/1;
t[100]=((u[100]-r[100])*60)/1;
y[100]=(((u[100]-r[100])*60-t[100])*60)/1;
#ifdef
run
cout<<"-------------------------------------------"<<"推算到起始边时,推算的坐标方位角为:"<<r[100]<<"°"<<t[100]<<"′"<<y[100]<<"″"<<endl;
#endif
if(r[100]!=r[1]&&t[100]!=t[1]&&y[100]!=y[1])
////有点问题
{
cout<<"推算的坐标方位角与原角不相等,查明原因直至符合!!!"<<endl;
}
else
{
for(i=1;i<=n;i++)
{
u[i]=u[i]*(pi/180);
}
cout<<"推算的坐标方位角与原角相等,接下来计算坐标增量。"<<endl<<endl;
for(i=1;i<=n;i++)
{
e[i]=long
double(e[i]*pi/180);
}
for(i=1;i<=n;i++)
{
x[i+1]=d[i]*sin(u[i]);
y[i+1]=d[i]*cos(u[i]);
if(x[i+1]>0)
{
x[i+1]=int(x[i+1]*100+0.5)/100.0;
}
else
{
x[i+1]=int(x[i+1]*100-0.5)/100.0;
//四舍五入保留2位小数
}
if(y[i+1]>0)
{
y[i+1]=int(y[i+1]*100+0.5)/100.0;
}
else
{
y[i+1]=int(y[i+1]*100-0.5)/100.0;
}
sum=sum+x[i+1];
Sum=Sum+y[i+1];
#ifdef
run
cout<<"-----------------------------------"<<i<<"导线纵坐标增量为"<<y[i+1]<<"m"<<"----"<<"横坐标增量为"<<x[i+1]<<"m"<<endl;
#endif
}
#ifdef
run
cout<<"纵坐标增量闭合差为"<<Sum<<"米"<<"
"<<"横坐标增量闭合差为"<<sum<<"米"<<endl;
#endif
f=sqrt(pow(sum,2)+pow(Sum,2));
K=double(f/g);
#ifdef
run
cout<<"导线全长闭合差为"<<f<<"米"<<","<<setiosflags(ios::fixed)<<setprecision(5)<<"导线全长相对闭合差为"<<K<<"米"<<endl;
#endif
yunxu=0.0005;
if(K>=yunxu)
{
cout<<"成果不合格!!!"<<endl;
//you wen
ti
}
else
{
cout<<"符合精度要求"<<endl;
for(i=1;i<=n;i++)
{
if(sum<0)
{
vx[i]=int(-sum*d[i]*100/g+0.5)/1.0;
}
else
{
vx[i]=int(-sum*d[i]*100/g-0.5)/1.0;
//四舍五入取整
}
if(Sum<0)
{
vy[i]=int(-Sum*d[i]*100/g+0.5)/1.0;
}
else
{
vy[i]=int(-Sum*d[i]*100/g-0.5)/1.0;
}
he=he+vx[i];
He=He+vy[i];
#ifdef
run
cout<<i<<"导线点"<<"横坐标增量改正数为"<<vx[i]<<"厘米"<<","<<"纵坐标增量改正数为"<<vy[i]<<"厘米"<<endl;
#endif
}
#ifdef
run
cout<<"横坐标增量改正数之和为"<<he<<"厘米"<<","<<"纵坐标增量改正数之和为"<<He<<"厘米"<<endl;
#endif
if(he==-sum&&He==-Sum)
{
for(i=1;i<=n;i++)
{
x[i+1]=x[i+1]+float(vx[i]/100);
y[i+1]=y[i+1]+float(vy[i]/100);
#ifdef
run
cout<<"改正后的"<<i<<"导线纵坐标增量为"<<x[i+1]<<"米"<<","<<"横坐标增量为"<<y[i+1]<<"米"<<endl;
#endif
}
}
chazhi1=he+sum*100;
chazhi2=He+Sum*100;
#ifdef
run
cout<<chazhi1<<"
"<<chazhi2<<endl;
#endif
if(chazhi1>0&&chazhi2==0)
{
#ifdef
run
cout<<"横坐标改正多了"<<chazhi1<<"厘米"<<endl;
#endif
for(i=1;i<=abs(chazhi1);i++)
{
b[i]=diao2(min,j,n,i,U,b,d);
vx[b[i]]=vx[b[i]]-1;
#ifdef
run
cout<<b[i]<<"导线点横坐标少改正1cm"<<endl;
#endif
}
}
if(chazhi1<0&&chazhi2==0)
{
#ifdef
run
cout<<"横坐标改正少了"<<chazhi1<<"厘米"<<endl;
//坐标增量误差的自动更正
#endif
for(i=1;i<=abs(chazhi1);i++)
{
diao(max,j,n,i,U,B,d);
vx[B[i]]=vx[B[i]]+1;
#ifdef
run
cout<<B[i]<<"导线点横坐标多改正1cm"<<endl;
#endif
}
}
if(chazhi1==0&&chazhi2>0)
{
#ifdef
run
cout<<"纵坐标改正多了"<<chazhi1<<"厘米"<<endl;
#endif
for(i=1;i<=abs(chazhi2);i++)
{
diao2(min,j,n,i,U,b,d);
vy[b[i]]=vy[b[i]]-1;
#ifdef
run
cout<<b[i]<<"导线点纵坐标少改正1cm"<<endl;
#endif
}
}
if(chazhi1==0&&chazhi2<0)
{
#ifdef
run
cout<<"纵坐标改正少了"<<chazhi1<<"厘米"<<endl;
#endif
for(i=1;i<=abs(chazhi2);i++)
{
diao(max,j,n,i,U,B,d);
vy[B[i]]=vy[B[i]]+1;
#ifdef
run
cout<<B[i]<<"导线点纵坐标多改正1cm"<<endl;
#endif
}
}
if(chazhi1>0&&chazhi2>0)
{
#ifdef
run
cout<<"横坐标改正多了"<<chazhi1<<"厘米"<<","<<"纵坐标改正多了"<<chazhi2<<"厘米"<<endl;
#endif
for(i=1;i<=abs(chazhi1);i++)
{
b[i]=diao2(min,j,n,i,U,b,d);
vx[b[i]]=vx[b[i]]-1;
#ifdef
run
cout<<b[i]<<"导线点横坐标少改正1cm"<<endl;
#endif
}
for(i=1;i<=abs(chazhi2);i++)
{
diao2(min,j,n,i,U,b,d);
vy[b[i]]=vy[b[i]]-1;
#ifdef
run
cout<<b[i]<<"导线点纵坐标少改正1cm"<<endl;
#endif
}
}
if(chazhi1>0&&chazhi2<0)
{
#ifdef
run
cout<<"横坐标改正多了"<<chazhi1<<"厘米"<<","<<"纵坐标改正少了"<<chazhi2<<"厘米"<<endl;
#endif
for(i=1;i<=abs(chazhi1);i++)
{
diao2(min,j,n,i,U,b,d);
vx[b[i]]=vx[b[i]]-1;
#ifdef
run
cout<<b[i]<<"导线点横坐标少改正1cm"<<endl;
#endif
}
for(i=1;i<=abs(chazhi2);i++)
{
diao(max,j,n,i,U,B,d);
vy[B[i]]=vy[B[i]]+1;
#ifdef
run
cout<<B[i]<<"导线点纵坐标多改正1cm"<<endl;
#endif
}
}
if(chazhi1<0&&chazhi2>0)
{
#ifdef
run
cout<<"横坐标改正少了"<<chazhi1<<"厘米"<<","<<"纵坐标改正多了"<<chazhi2<<"厘米"<<endl;
#endif
for(i=1;i<=abs(chazhi1);i++)
{
diao(max,j,n,i,U,B,d);
vx[B[i]]=vx[B[i]]+1;
#ifdef
run
cout<<B[i]<<"导线点横坐标多改正1cm"<<endl;
#endif
}
for(i=1;i<=abs(chazhi2);i++)
{
diao2(min,j,n,i,U,b,d);
vy[b[i]]=vy[b[i]]-1;
#ifdef
run
cout<<b[i]<<"导线点纵坐标少改正1cm"<<endl;
#endif
}
}
if(chazhi1<0&&chazhi2<0)
{
#ifdef
run
cout<<"横坐标改正少了"<<chazhi1<<"厘米"<<","<<"纵坐标改正少了"<<chazhi2<<"厘米"<<endl;
#endif
for(i=1;i<=abs(chazhi1);i++)
{
diao(max,j,n,i,U,B,d);
vx[B[i]]=vx[B[i]]+1;
#ifdef
run
cout<<B[i]<<"导线点横坐标多改正1cm"<<endl;
#endif
}
for(i=1;i<=abs(chazhi2);i++)
{
diao(max,j,n,i,U,B,d);
vy[B[i]]=vy[B[i]]+1;
#ifdef
run
cout<<B[i]<<"导线点纵坐标多改正1cm"<<endl;
#endif
}
}
for(i=1;i<=n;i++)
{
x[i+1]=x[i+1]+(float)vx[i]/100;
y[i+1]=y[i+1]+(float)vy[i]/100;
#ifdef
run
cout<<i<<"导线点的横坐标增量为"<<setiosflags(ios::fixed)<<setprecision(2)<<x[i+1]<<"m"<<","<<"纵坐标增量为"<<y[i+1]<<"m"<<endl;
#endif
}
cout<<"输入导线点1的坐标(xh[1],yz[1]):"<<endl;
cin>>xh[1]>>yz[1];
for(i=2;i<=n;i++)
{
xh[i]=xh[i-1]+x[i];
yz[i]=yz[i-1]+y[i];
}
for(i=1;i<=n;i++)
{
#ifdef
run
cout<<i<<"导线点的坐标为"<<setiosflags(ios::fixed)<<setprecision(2)<<"("<<xh[i]<<","<<yz[i]<<")"<<endl;
#endif
}
xh[n+1]=xh[n]+x[n+1];
yz[n+1]=yz[n]+y[n+1];
cout<<setiosflags(ios::fixed)<<setprecision(2)<<"推算出的起始坐标为("<<xh[n+1]<<","<<yz[n+1]<<")"<<endl<<endl;
cout<<"-----------------------------------"<<"恭喜你!!!已经完成了闭合导线测量的内业计算!!!各导线点的坐标为:"<<endl;
for(i=1;i<=n;i++)
{
cout<<setiosflags(ios::fixed)<<setprecision(2)<<"
"<<i<<"
"<<"("<<xh[i]<<","<<yz[i]<<")"<<endl;
}
}
}
}
return
0;
}
int diao(long double max,int j,int n,int i,int U,int
B[100],long double
d[100])
//调用的函数
{
max=0;
for(j=1;j<=n;j++)
{
if(i>=2)
{
for(U=1;U<i;U++)
{
if(j==B[1]||j==B[2]||j==B[3]||j==B[4]||j==B[5]||j==B[6]||j==B[7]||j==B[8]||j==B[9]||j==B[10]||j==B[11]||j==B[12]||j==B[13]||j==B[14]||j==B[15]||j==B[16]||j==B[17]
||j==B[18]||j==B[19]||j==B[20]||j==B[21]||j==B[22]||j==B[23]||j==B[24]||j==B[25]||j==B[26]||j==B[27]||j==B[28]||j==B[29]||j==B[30]||j==B[31]||j==B[32]||j==B[33]
||j==B[34]||j==B[35]||j==B[36]||j==B[37]||j==B[38]||j==B[39]||j==B[40]||j==B[41]||j==B[42]||j==B[43]||j==B[44]||j==B[45]||j==B[46]||j==B[47]||j==B[48]||j==B[49])
{
j++;
}
}
}
if(j>n)
break;
else
{
max=(d[j]>max)?d[j]:max;
}
}
for(j=1;j<=n;j++)
{
if(max==d[j])
{
B[i]=j;
}
}
return 0;
}
int diao2(long double
min,int j,int n,int i,int U,int b[100],long double
d[100])
{
min=100000;
for(j=1;j<=n;j++)
{
if(i>=2)
{
for(U=1;U<i;U++)
{
if(j==b[1]||j==b[2]||j==b[3]||j==b[4]||j==b[5]||j==b[6]||j==b[7]||j==b[8]||j==b[9]||j==b[10]||j==b[11]||j==b[12]||j==b[13]||j==b[14]||j==b[15]||j==b[16]||j==b[17]
||j==b[18]||j==b[19]||j==b[20]||j==b[21]||j==b[22]||j==b[23]||j==b[24]||j==b[25]||j==b[26]||j==b[27]||j==b[28]||j==b[29]||j==b[30]||j==b[31]||j==b[32]||j==b[33]
||j==b[34]||j==b[35]||j==b[36]||j==b[37]||j==b[38]||j==b[39]||j==b[40]||j==b[41]||j==b[42]||j==b[43]||j==b[44]||j==b[45]||j==b[46]||j==b[47]||j==b[48]||j==b[49])
{
j++;
}
}
}
if(j>n)
break;
else
{
min=(d[j]<min)?d[j]:min;
}
}
for(j=1;j<=n;j++)
{
if(min==d[j])
{
b[i]=j;
}
}
return b[i];
}
标签:style class blog c http color
原文地址:http://www.cnblogs.com/zzkgis/p/3742597.html