Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <fstream>
- #include <string>
- using namespace std;
- struct point {
- double x, y;
- };
- ifstream in("input.txt");
- ofstream out("output.txt");
- int main()
- {
- int n;
- in >> n;
- point t, a[10];
- for (int i = 0; i < n; i++) {
- in >> a[i].x >> a[i].y;
- }
- double* b = new double[n];
- for (int i = 0; i < n; i++) {
- b[i] = 0;
- for (int j = 0; j < n; j++) {
- b[i] += sqrt(pow((a[i].x - a[j].x), 2) + pow((a[i].y - a[j].y), 2));
- }
- }
- int d = 1;
- double minim = b[0] + 1;
- for (int i = 0; i < n; i++) {
- if (b[i] < minim) {
- minim = b[i];
- d = i + 1;
- }
- }
- out << d;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement