首页 > 代码库 > Airline Hub
Airline Hub
参考:http://blog.csdn.net/mobius_strip/article/details/12731459
#include <stdio.h>#include <cmath>#include <iostream>struct Point{ double lat, lon;};double dist(double lat1, double lon1, double lat2, double lon2){ double p = acos(-1.0); lat1 *= p / 180.0; lon1 *= p / 180.0; lat2 *= p / 180.0; lon2 *= p / 180.0; return cos(lat1)*cos(lat2)*cos(lon1 - lon2) + sin(lat1)*sin(lat2);}int main(){ const int count = 1001; static Point pts[count]; static double dis[count][count]; int n; std::cin >> n; for (int i = 0; i < n; ++i) { std::cin >> pts[i].lat >> pts[i].lon; } for (int i = 0; i < n; ++i) { for (int j = 0; j < n; ++j) { dis[i][j] = dis[j][i] = dist(pts[i].lat, pts[i].lon, pts[j].lat, pts[j].lon); } } double min = dis[0][1]; int hub = 0; for (int i = 0; i < n; ++i) { double max = 0.0; for (int j = 0; j < n; ++j) { if (max < dis[i][j]) { max = dis[i][j]; } } if (min > max) { min = max; hub = i; } } printf("%0.2f %0.2f\n",pts[hub].lat,pts[hub].lon); return 0;}
Airline Hub
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。