Pagini recente » Cod sursa (job #1109126) | Cod sursa (job #1861877) | Cod sursa (job #1298922) | Cod sursa (job #901014) | Cod sursa (job #1017179)
#include <stdio.h>
#include <math.h>
typedef long long mlong;
inline double dist(mlong x, mlong y, mlong x2, mlong y2)
{
return sqrt((x2 - x) * (x2 - x) + (y2 - y) * (y2 - y));
}
int main()
{
int n;
mlong *a, *b;
FILE *fin = fopen("cmap.in", "r");
fscanf(fin, "%d", &n);
a = (mlong*)malloc(n * sizeof(mlong));
b = (mlong*)malloc(n * sizeof(mlong));
int i, j;
for(i = 0; i < n; i++)
fscanf(fin, "%Ld %d", a + i, b + i);
double mDist = 0x3f3f3f3f3f, cDist;
for(i = 0; i < n; i++)
for(j = i + 1; j < n; j++)
if((cDist = dist(a[i],b[i],a[j],b[j])) < mDist)
mDist = cDist;
FILE *fout = fopen("cmap.out", "w");
fprintf(fout, "%6f", mDist);
}