Correct off-by-one error in avg distance and avoid division by zero

sql-rework
Tomasz Golinski 2020-01-25 16:15:21 +01:00
rodzic 5296e11a21
commit 849eeaf1a5
1 zmienionych plików z 2 dodań i 1 usunięć

Wyświetl plik

@ -287,7 +287,8 @@ int main(int argc, char** argv) {
tot_dist += cache_distance(*i->second, *std::next(i)->second);
}
std::cout << "Total distance between caches: <span class=\"value\">" << tot_dist << "</span> km (equivalent to <span class=\"value\">" << tot_dist / (2 * Pi * Earth_radius) << "x</span> trips around Earth)<br>\n";
std::cout << "Average distance between caches: <span class=\"value\">" << tot_dist / sorted_fcaches.size() << "</span> km<br>\n";
if (sorted_fcaches.size() > 1)
std::cout << "Average distance between caches: <span class=\"value\">" << tot_dist / (sorted_fcaches.size() - 1) << "</span> km<br>\n";
std::cout << "</div>\n";
}