1. 程式人生 > >hdu-1173(最短距離)

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; }