求助
查看原帖
求助
561638
Tanhaoyue2011楼主2025/7/22 15:37

我不知道我错哪里了。。。

#include<iostream>
#include<cmath>
#include<cstdio>

using namespace std;

struct Point{
	int x,y;
};
Point p[10005];
int n, minn = 1e7, s = 1;
int len;
int main(){
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> p[i].x >> p[i].y;
	}
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= n - s; j++){
			len = sqrt(pow((p[i].x - p[j].x), 2) + pow((p[i].y - p[j].y), 2));
			s++;
			if(len < minn) minn = len;
		}
	}
	printf("%.4lf", (double)minn);
	return 0;
}

2025/7/22 15:37
加载中...