w do I correct this into the correct format: The input begins with the number of locations. Each location is entered x and then y and then name. Output the name of the closest locations.
w do I correct this into the correct format: The input begins with the number of locations. Each location is entered x and then y and then name. Output the name of the closest locations.
w do I correct this into the correct format: The input begins with the number of locations. Each location is entered x and then y and then name. Output the name of the closest locations.
// Each row in points represents a location Location location[NUMBER_OF_POINTS];
// make sure to enter the name of the location so like // longview 237.89 46.68 // dallas 373.62 47.0
cout << "Enter " << NUMBER_OF_POINTS << " points: "; for (int i = 0; i < NUMBER_OF_POINTS; i++) cin >> location[i].name >> location[i].x >> location[i].y; // allow the user to enter name by adding ">> location[i].name"
//p1 and p2 are the indices in the locations array int p1 = 0, p2 = 1; double shortestDistance = getDistance(location[p1].x, location[p1].y, location[p2].x, location [p2].y);//Initialize shortestDistance
//Compute distance for every two points for (int i = 0; i < NUMBER_OF_POINTS; i++) { for (int j = 0; j < NUMBER_OF_POINTS; j++) { double distance = getDistance(location[i].x, location[i].y, location[j].x, location[j].y); //Find distance if (i == j) continue;
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.