Find latitude and longitude of 20 countries with a population greater than or equal to the population limit given below. Use the country details from this dataset.
Your task is to find the sum of the length of all lines (in kms) that can be drawn between co-ordinates of these countries.
Population limit: 300
Note: Population limit will change at random intervals. So please make sure answer is computed for the correct population limit before submitting.
#include <stdio.h>
#include <cmath.h>
struct coordinate {
double latutude, longitude
}
typedef struct coordinate coor_t
double calc_dist(coor_t coor1, coor_t coor2)
{
double latitude1 = coor1.latitude * PI / 180;
double longitude1 = coor1.longitude * PI / 180;
double latitude2 = coor2.latitude * PI / 180;
double longitude2 = coor2.longitude * PI / 180;
double d = 2 * 6371 * asin(sqrt(sin(pow((latitude2 - latitude1) / 2, 2)) +
cos(latitude1) * cos(latitude2) * sin(pow((longitude2 - longitude1) / 2, 2))));
return round(d, 2);
}
const char *file = "countries.csv";
const int limit = 300;
int main() {
// need parse file and cacl total dist using calc_dist function
return 0;
}
Comments
Leave a comment