Cod sursa(job #2664418)

Utilizator MattiaMattia Iojica Mattia Data 28 octombrie 2020 16:48:09
Problema Cele mai apropiate puncte din plan Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.8 kb
#include <bits/stdc++.h>
#define NMAX 100005

using namespace std;

ifstream f("cmap.in");
ofstream g("cmap.out");

struct punct{
    int x, y;
}a[NMAX];

float distanta(int i, int j)
{
    int x1 = a[i].x - a[j].x;
    int x2 = a[i].y - a[j].y;
    float dist = sqrt(x1 * x1 + x2 * x2);

 //   cout << dist << '\n';

    return dist;
}

int main()
{
    int n;
    float mini = 1e9;

    f >> n;

    for(int i = 1; i <= n; i++)
    {
        int st, dr;
        f >> st >> dr;

        a[i].x = st;
        a[i].y = dr;
    }

    for(int i = 1; i < n; i++)
        for(int j = i + 1; j <= n; j++)
        {
            float dist = distanta(i, j);
          //  cout << dist << '\n';
            mini = min(mini, dist);
        }

    g << mini;

    return 0;
}