# 平面4点最小距离

``````10,10
20,20
80,50
10,20
20,10``````

``11.38``

``````#include <stdio.h>
#include <math.h>
struct dian
{
double x;
double y;
};
double ll(dian a,dian b)
{
return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2));
}
double round(double a)
{
if((a*100)+0.5>(int)(a*100)+1)return ((int)(a*100)+1)/100.0;
else return (int)(a*100)/100.0;
}
double deal(dian a,dian b,dian c,dian d)
{
double s=0.0;
s+=round(ll(a,b));
s+=round(ll(a,c));
s+=round(ll(a,d));
s+=round(ll(b,c));
s+=round(ll(b,d));
s+=round(ll(c,d));
return s/6.0;
}
int main()
{
struct dian a[50];
double minn=0xffff;
int i=0;
for(i=0; ~scanf("%lf%*c%lf",&a[i].x,&a[i].y); i++);
for(int j=0; j<i; j++)
for(int k=j+1; k<i; k++)
for(int l=k+1; l<i; l++)
for(int s=l+1; s<i; s++)
{
double de=deal(a[j],a[k],a[l],a[s]);
minn=minn>de?de:minn;
}
printf("%.2lf\n",minn);
return 0;
}
``````

``````#include <stdio.h>
#include <math.h>
struct dian
{
double x;
double y;
};
double ll(dian a,dian b)
{
return sqrt(pow(a.x-b.x,2)+pow(a.y-b.y,2));
}
double round(double a)
{
if((a*100)+0.5>(int)(a*100)+1)return ((int)(a*100)+1)/100.0;
else return (int)(a*100)/100.0;
}
double deal(dian a,dian b,dian c,dian d)
{
double s=0.0;
s+=round(ll(a,b));
s+=round(ll(a,c));
s+=round(ll(a,d));
s+=round(ll(b,c));
s+=round(ll(b,d));
s+=round(ll(c,d));
return s/6.0;
}
int main()
{
struct dian a[50];
double minn=0xffff;
int i=0;
for(i=0; ~scanf("%lf%*c%lf",&a[i].x,&a[i].y); i++);
for(int j=0; j<i; j++)
for(int k=j+1; k<i; k++)
for(int l=k+1; l<i; l++)
for(int s=l+1; s<i; s++)
{
double de=deal(a[j],a[k],a[l],a[s]);
minn=minn>de?de:minn;
}
printf("%.2lf\n",minn);
return 0;
}
``````