#include
#include
#include
using namespace std;
int main()
{
int N,i,j,k=0;

double min;
while (cin >> N&&N)
{
double x = new double[N];
double *y = new double[N];
double *d = new double[N
(N-1)];
for (i = 0; i < N; i++)
cin >> x[i] >> y[i];
for (i = 0; i < N-1; i++)
{
for (j = i + 1; j < N; j++)
{
if (x[i] == x[j] && y[i] == y[j]) d[k] = 0;
else d[k] = (x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]);
k++;
}
}
min = d[0];
for (k = 0; k < N*(N - 1) / 2; k++)
if (min > d[k]) min = d[k];
if(min!=0) min = sqrt(min)/2;
cout << setprecision(2) << fixed << min << endl;
delete []x, y, d;
}
return 0;
}

2
1 1
1 1

1个回答

`````` int main()
{
int N,i,j,k=0;

double min;
while (cin >> N&&N)
{
double *x = new double[N];
double *y = new double[N];
double *d = new double[N-1];
for (i = 0; i < N; i++)
cin >> x[i] >> y[i];
for (i = 0; i < N-1; i++)
{
for (j = i + 1; j < N; j++)
{
if (x[i] == x[j] && y[i] == y[j])
d[k] = 0;
else
d[k] = (x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]);
k++;
}
}
min = d[0];
for (k = 0; k < N*(N - 1) / 2; k++)
{
if (min > d[k])
min = d[k];
}
if(min!=0)
min = sqrt(min)/2;
cout << setprecision(2) << fixed << min << endl;
k = 0;  ////////////////////////
delete x, y, d;
}
return 0;
}
``````

shen_wei 自己好好对比吧。。里面的差别你没有看出来？？