资源描述:
《附合导线计算程序设计.doc》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、5附合导线计算程序设计#include#definePI3.1415926#include#defineLENsizeof(structnode)#includestructzuobiao{doublex;doubley;};structangle{intdegree;intminute;floatsecond;};structnode{doublex;doubley;structangleang1;structanglefwj;doubles;doubledx;doubledy;structnode*next;};do
2、ublejtod(structanglejiao){doubledegree;degree=jiao.degree;degree+=(jiao.minute/60.0);degree+=(jiao.second/3600.0);returndegree;}structangledtoj(doublejiaodu){structanglefwj;fwj.degree=floor(jiaodu);fwj.minute=floor((jiaodu-floor(jiaodu))*60);fwj.second=((jiaodu-floor(jiaodu))*60-fwj.minute
3、)*60;returnfwj;}doublejtoh(structanglejiaodu){doublehu;hu=jtod(jiaodu);hu=hu*PI/180;returnhu;}main(){FILE*fp;structzuobiaozb0,zbN;structnode*head,*p1,*p2;structangleangle1,f0,fB,fN;intn,i;doublet,fBsecond,jiaodu;doublefX=0,fY=0,K=0,S=0;fB.degree=0;fB.minute=0;fB.second=0;if((fp=fopen("d:\
4、pro\data2.txt","r"))==NULL)printf("cannotopenthisfile");fscanf(fp,"%d",&n);fscanf(fp,"%lf%lf",&zb0.x,&zb0.y);fscanf(fp,"%d%d%f",&f0.degree,&f0.minute,&f0.second);fscanf(fp,"%lf%lf",&zbN.x,&zbN.y);fscanf(fp,"%d%d%f",&fN.degree,&fN.minute,&fN.second);fB.degree=f0.degree;fB.minute=f0.minut
5、e;fB.second=f0.second;fBsecond=jtod(fB);for(i=0;i360)fBsecond-=360;if(fBsecond<0)fBsecond+=360;}fBsecond-=jtod(fN);fBsecond*=3600;printf("%lf",fBsecond);fBsecond/=-n;
6、rewind(fp);for(i=0;i<11;i++)fscanf(fp,"%lf",&t);head=p1=p2=(structnode*)malloc(LEN);//fscanf(fp,"%d%d%f",&p1->fwj.degree,&p1->fwj.minute,&p1->fwj.second);for(i=0;iang1.degree,&p1->ang1.minute,&p1->ang1.second);p1->ang1.second+=fBsecond;if(p1->ang1.second>=60
7、){p1->ang1.second-=60;p1->ang1.minute+=1;if(p1->ang1.minute>=60){p1->ang1.minute-=60;p1->ang1.degree+=1;}}if(p1->ang1.second<0){p1->ang1.second+=60;p1->ang1.minute-=1;if(p1->ang1.minute<0){p1->ang1.minute+=60;p1->ang1.degree-=1;}}p2->next=p1;p2=p1;p1=(structno