注意精度高点没错的
View Code
#include<stdio.h>
#include<math.h>
#define R 6378.00
#define PI 3.1415926535
#define hu 360/3.1415926535/2
int main()
{
int t;
double x1,y1,z1,x2,y2,z2,th1,th2,a1,a2,dis,q;
scanf("%d",&t);
while(t--)
{
double a=sin(30/hu);
scanf("%lf%lf%lf%lf",&th1,&a1,&th2,&a2);
th1/=hu;
a1/=hu;
th2/=hu;
a2/=hu;
x1=R*cos(th1)*sin(a1);
y1=R*cos(th1)*cos(a1);
z1=R*sin(th1);
x2=R*cos(th2)*sin(a2);
y2=R*cos(th2)*cos(a2);
z2=R*sin(th2);
dis=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)+(z1-z2)*(z1-z2));
q=2*asin(dis/2.0/R)*R;
printf("%.2lf\n",q);
}
}