Cod sursa(job #2213237)

Utilizator unknownpersonBidasca Carina Georgiana unknownperson Data 15 iunie 2018 21:01:37
Problema Cele mai apropiate puncte din plan Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.73 kb
#include<bits/stdc++.h>
using namespace std;
ifstream f("cmap.in");
ofstream g("cmap.out");
#define nmax 100002
struct point
{
    int x,y;
};
int n;
point v[nmax];
double min=1000000000.0;

double dist(point p1, point p2)
{
    return sqrt((double)((long long)((long long)p1.x-p2.x)*(p1.x-p2.x)+(long long)((long long)p1.y-p2.y)*(p1.y-p2.y)));
}

int main()
{

    f>>n;
    int i,j,ci,cj;
    double d;
    for(i=1;i<=n;i++)
        f>>v[i].x>>v[i].y;
    for(i=1;i<n;i++)
        for(j=i+1;j<=n;j++)
        {
            d=dist(v[i],v[j]);
            if(d<minim)
            {
                ci=i;
                cj=j;
                minim=d;
            }
        }
    g<<minim;

    return 0;
}