Pagini recente » Cod sursa (job #2355271) | Cod sursa (job #2095252) | Cod sursa (job #25845) | Cod sursa (job #2402646) | Cod sursa (job #411937)
Cod sursa(job #411937)
#include <cstdio>
#include <cmath>
struct point
{
double x, y;
} P[100005];
int n;
double d(point a, point b)
{
return sqrt(pow((a.x - b.x), 2) + pow((a.y - b.y),2));
}
double min(double a, double b)
{
return a<b?a:b;
}
int main()
{
FILE *f = fopen("cmap.in", "r");
fscanf(f, "%d", &n);
for (int i = 1 ; i <= n; ++i)
fscanf(f, "%lf%lf", &P[i].x, &P[i].y);
fclose(f);
double dmin = 1<<30;
for (int i = 1 ; i <= n; ++i)
for (int j = 1 ; j <= n; ++j)
if (i!=j)
dmin = min(dmin, d(P[i], P[j]));
f = fopen("cmap.out","w");
fprintf (f, "%lf\n", dmin);
fclose(f);
return 0;
}