hdu-1173(最短距离)

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1173

思路:最短距离:就是现将x,y从小到大排序,然后去中间点就行了。(注意:本题答案不唯一)

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int maxn = 1000200;
double x[maxn],y[maxn];
int main(void)
{
    int n,i;
    while(~scanf("%d",&n)&&n)
    {
        for(i=0;i<n;i++) scanf("%lf%lf",&x[i],&y[i]);
        sort(x,x+n);
        sort(y,y+n);
        printf("%.2lf %.2lf\n",x[n/2],y[n/2]);
    }
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/2018zxy/p/9934572.html