Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Security XI Status And Prospects

Authors: T.Y. Lin, Shelly Qian

1st Edition

0412820900, 978-0412820908

More Books

Students also viewed these Databases questions

Question

Detailed note on the contributions of F.W.Taylor

Answered: 1 week ago