其他分享
首页 > 其他分享> > csp认证2020-09-1称检测点查询

csp认证2020-09-1称检测点查询

作者:互联网

100分代码
在这里插入图片描述

#include<bits/stdc++.h>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int a[1001][3];
//int f[1001];
struct node {
	int k;//序号 
	double f;//距离 
}p[1001];
int main() {
	int n;
	int X, Y;
	scanf("%d%d%d", &n, &X, &Y);

	for (int i = 1; i <= n; i++) {
		scanf("%d%d", &a[i][0], &a[i][1]);
		p[i].k = i;
		p[i].f = sqrt(pow((a[i][0]-X), 2) + pow((a[i][1]-Y), 2));
	}

	for (int i = 1; i <= n-1; i++)
	{
		for (int j = 1; j <= n-i; j++) {
			if (p[j].f > p[j+1].f) {
				int t = p[j+1].f;
				p[j+1].f = p[j].f;
				p[j].f = t;
				int h = p[j+1].k;
				p[j+1].k = p[j].k;
				p[j].k = h;
			}
		}
	}
	for (int i = 1; i <= 3; i++) {
		printf("%d", p[i].k);
		printf("\n");
	}
}

标签:检测点,int,pow,d%,2020,09,printf,include,1001
来源: https://blog.csdn.net/qq_45771066/article/details/120373717