Pagini recente » Cod sursa (job #2927933) | Cod sursa (job #548472) | Cod sursa (job #124065) | Cod sursa (job #2546367) | Cod sursa (job #902011)
Cod sursa(job #902011)
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
using namespace std;
FILE *f=fopen("cmap.in","r");
FILE *g=fopen("cmap.out","w");
int i,j,n;
double mn;
struct vect
{
int x,y;
}v[100001];
bool cmp(vect i,vect j)
{
if (i.x<j.x) return 1;
else if (i.x==j.x && i.y<j.y) return 1;
else return 0;
}
double dst(vect i, vect j)
{
return sqrt((i.x-j.x)*(i.x-j.x) + (i.y-j.y)*(i.y-j.y));
}
int main()
{
fscanf(f,"%d",&n);
for (i=1;i<=n;i++)
fscanf(f,"%d %d",&v[i].x,&v[i].y);
sort(v+1,v+n+1,cmp);
mn=dst(v[1],v[n]);
for (i=1;i<=n;i++)
for (j=i+1;j<=i+7;j++)
if (dst(v[i],v[j])<mn) { mn=dst(v[i],v[j]);}
fprintf(g,"%.6lf",mn);
fclose(g); fclose(f);
return 0;
}