uva 10245 The Closest Pair Problem

这道题是给大家寻开心的,灵光一闪,你就会了,我写这份报告也是寻开心的。。。。。。。。。。。。。。。我就笑了。。。。。你可以先做这一道玩玩。。。哒哒哒。。。。啊啦上海侬
#include <cstdio>
#include <cmath>
struct point{
    double x;
    double y;

};
/*
struct edge
{
    point a;
    point b;
    double dis;
};
*/
double diss( point a,point b)
{
    return sqrt((a.x-b.x)*(a.x-b.x) + (a.y-b.y)*(a.y- b.y));
}
int main()
{
    int n,i,j;
    point p[10010];
    //edge e[10010];
    while(scanf("%d",&n)&&n)
    {

        double MIN,_min;
        MIN = 1 << 30;
        for( i = 0; i < n; i ++)
        {
            scanf("%lf %lf",&p[i].x,&p[i].y);
        }
        for(i =0;i < n-1;i++)
        {
            for(j=i+1;j<n;j++)
            {
                _min = diss(p[i],p[j]);
                if(_min < MIN)
                {
                    MIN = _min;
                }
            }
        }
        if(MIN >= 10000)
            printf("INFINITY\n");
        else
            printf("%.4lf\n",MIN);
    }
    return 0;
}

你可能感兴趣的:(uva 10245 The Closest Pair Problem)