大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。
Jetbrains全系列IDE稳定放心使用
#include <math.h>
#define EARTH_RADIUS 6378.137//地球半径
#define PI 3.14159265358979323846 //圆周率
//角度转化为弧度
static double rad(double d)
{
return d * PI / 180.0;
}
double GetDistance(double lat1, double lng1, double lat2, double lng2)
{
double radLat1 = rad(lat1);
double radLat2 = rad(lat2);
double a = radLat1 – radLat2;
double b = rad(lng1) – rad(lng2);
double s = 2 * asin(sqrt(pow(sin(a/2),2) +
cos(radLat1)*cos(radLat2)*pow(sin(b/2),2)));
s = s * EARTH_RADIUS;
//s = round(s * 10000) / 10000;
s = llroundl(s*10000) / 10000.0;
//s = double b = ( ( int )( a * 1000000 + 0.5 ) ) / 1000000.0;//round(11111111.21);
//s = s/10000;
return s;
}
int main()
{
double dist = GetDistance(0,1, 0, 1.001 );
printf(“1.dist=%f\n”, dist );
dist = GetDistance(90-24.0,0, 90+24.01, 0 );
printf(“2.dist=%f\n”, dist );
dist = GetDistance(24.0,5, -24, -1 );
printf(“3.dist=%f\n”, dist );
dist = GetDistance(24,5, 24, -1 );
printf(“4.dist=%f\n”, dist );
dist = GetDistance(48,5, 24, -1 );
printf(“5.dist=%f\n”, dist );
dist = GetDistance(-50.0,120, -10, 120 );
printf(“6.dist=%f\n”, dist );
while(1);
return 0;
}
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/190383.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...