From c29f97546a04c51e8efdcfa01dc2ac27d770a98d Mon Sep 17 00:00:00 2001 From: Tomasz Golinski Date: Sun, 5 Sep 2021 19:47:13 +0200 Subject: [PATCH] Add distance to the Moon --- cache.h | 1 + geostat.cpp | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/cache.h b/cache.h index 2a76a46..f97fa83 100644 --- a/cache.h +++ b/cache.h @@ -39,6 +39,7 @@ enum Status { }; const int Earth_radius = 6378; +const int Moon_dist = 384400; class Position { public: diff --git a/geostat.cpp b/geostat.cpp index 4b14330..5c9e002 100644 --- a/geostat.cpp +++ b/geostat.cpp @@ -450,7 +450,7 @@ int main(int argc, char** argv) { //std::cout << "Distance between " << i->second->name << " and " << std::next(i)->second->name << " is " << cache_distance(*i->second, *std::next(i)->second) << "
"; tot_dist += cache_distance(*i->second, *std::next(i)->second); } - std::cout << "Total distance between caches: " << std::fixed << tot_dist << " km (equivalent to " << tot_dist / (2 * M_PI * Earth_radius) << "x trips around Earth)
\n"; + std::cout << "Total distance between caches: " << std::fixed << tot_dist << " km (equivalent to " << tot_dist / (2 * M_PI * Earth_radius) << "x trips around Earth or " << tot_dist / Moon_dist << "x trips to the Moon)
\n"; std::cout << std::resetiosflags(std::cout.flags()); if (sorted_fcaches.size() > 1) std::cout << "Average distance between caches: " << tot_dist / (sorted_fcaches.size() - 1) << " km
\n";