Question: With this code on C++: #include #include using namespace std; struct point { int x, y; }; int main() { point p; cout > p.x

With this code on C++:

#include #include

using namespace std;

struct point { int x, y; };

int main() { point p; cout > p.x >> p.y; int size = 10; point *arr = new point[size]; for(int i = 0; i > arr[i].x >> arr[i].y; } double *d = new double[size]; for(int i = 0; i d[j+1]) { ptemp.x = arr[j].x; ptemp.y = arr[j].y; arr[j].x = arr[j+1].x; arr[j+1].x = ptemp.x; arr[j].y = arr[j+1].y; arr[j+1].y = ptemp.y; dtemp = d[j]; d[j] = d[j+1]; d[j+1] = dtemp; } } } // print here cout

Add-on a function that moves the original point p.x and p.y to the next closest point once there the function uses the distance formula to find the closest point again to the new p.x and p.y. Do this until all ten points are hit.With this code on C++: #include #include using namespace std; struct point

Enter initial point: 0 0 Enter point 1: 11 Enter point 2: 5 2 Enter point 3: 53 Enter point 4: 1 3 Enter point 5: 1 6 Enter point 6: 8 3 Enter point 7: 9 2 Enter point 8: 9 7 Enter point 9: 1 6 Enter point 10: 4 4 Points from . in ascending order 4, 4 Process exited after 18.64 seconds with return ualue Press any key to continue

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!