题目
分析
也是sort,很简单
代码
#include<math.h>
#include<cstdio>
#include<algorithm>
using namespace std;
struct node {
int x;
int y;
int dis;
int nu;
};
node num[300];
bool cmp(node a, node b)
{
if (a.dis != b.dis)
return a.dis < b.dis;
else return a.nu < b.nu;
}
int main()
{
int n;int x, y;
scanf_s("%d %d %d", &n,&x,&y);
for (int i = 1;i <= n;i++)
{
num[i].nu = i;
scanf_s("%d %d", &num[i].x, &num[i].y);
num[i].dis= abs(num[i].x - x) * abs(num[i].x - x) + abs(num[i].y - y) * abs(num[i].y - y);
}
sort(num+1, num +1+ n, cmp);
for (int i = 1;i <= 3;i++)
{
printf("%d\n", num[i].nu);
}
}