Question: I wrote this program and i need to now how to find the points with the largest and smallest values of X and Y #include

I wrote this program and i need to now how to find the points with the largest and smallest values of X and Y

#include #include #include #include #include #include using namespace std;

double dis(int x, int y) { return x*x + y*y; } int main() { int x[100], y[100], n, temp; fstream in; in.open ("input.txt"); in >> n; for (int i = 0; i < n; i++) { in >> x[i]; in >> y[i]; cout << "(" << x[i] << "," << y[i] << ")" << endl; } for (int i = 0; i < n-1; i++) for (int j = i+1; j < n; j++) { if (dis(x[i], y[i]) > dis(x[j], y[j])) { temp = x[i]; x[i] = x[j]; x[j] = temp; temp = y[i]; y[i] = y[j]; y[j] = temp; } } cout << endl; for (int i = 0; i < n; i++) {

cout << "(" << x[i] << "," << y[i] << ")" << endl; }

}

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!