posts - 0,comments - 0,trackbacks - 0
Orz地理帝  地理帝威武。。
把所有的度数化为度得实数,然后用地理帝的公式一套就行。。公式太长记不住,自己到网上查吧。。
#include<stdio.h>
#include
<math.h>
#include
<stdlib.h>
long i;
long x1,x2,x3,yyy1,y2,y3,sx1,sx2,sx3,sy1,sy2,sy3;
double a1,b1,a2,b2,xx1,xx2,yy1,yy2,zz1,zz2,r,pi,ans,single,jl;
char xstr[5],ystr[5],sxstr[5],systr[5];
char str[10000];
int main()
{
  pi
=3.1415926;r=6875;r/=2;
  
for (i=1;i<=3;i++) gets(str);
  scanf(
"%d^%d'%d\" %s\n",&x1,&x2,&x3,&xstr);
  scanf("and %d^%d'%d\" %s\n",&yyy1,&y2,&y3,&ystr);
  gets(str);
  scanf(
"%d^%d'%d\" %s\n",&sx1,&sx2,&sx3,&sxstr);
  scanf("and %d^%d'%d\" %s\n",&sy1,&sy2,&sy3,&systr);
  gets(str);
  a1
=x1*3600+x2*60+x3;a1/=3600;if (xstr[0]=='N') a1=-a1;
  b1
=yyy1*3600+y2*60+y3;b1/=3600;if (ystr[0]=='E') b1=-b1;
  a2
=sx1*3600+sx2*60+sx3;a2/=3600;if (sxstr[0]=='N') a2=-a2; 
  b2
=sy1*3600+sy2*60+sy3;b2/=3600;if (systr[0]=='E') b2=-b2;
  a1
=(a1/180)*pi;b1=(b1/180)*pi;a2=(a2/180)*pi;b2=(b2/180)*pi;
  xx1
=r*cos(a1)*sin(b1);xx2=r*cos(a2)*sin(b2);
  yy1
=r*cos(a1)*cos(b1);yy2=r*cos(a2)*cos(b2);
  zz1
=r*sin(a1);zz2=r*sin(a2);
  jl
=xx1*xx2+yy1*yy2+zz1*zz2;
  single
=acos(jl/(r*r));
  ans
=r*single;
  printf(
"The distance to the iceberg: %0.2f miles.\n",ans);  
  
if (100>ans+0.005)
    printf(
"DANGER!");
}               

posted on 2011-07-05 23:02 梦转千寻 阅读(72) 评论(0)  编辑 收藏 引用

只有注册用户登录后才能发表评论。
网站导航:   博客园   博客园最新博文   博问   管理