跳到正文

个人记录

tmp 2025.12.13

Zhenggeek约 1 分钟
原文
文章信息与版本

文章信息

收录
2025年12月13日
更新
2025年12月13日
篇幅
约 1 分钟

版本

  1. v1当前
C++
#include<bits/stdc++.h>
using namespace std;

const int N = 1e4+10;
struct node{
	int x;
	int y;
}a[N];

double dist(node A,node B){
	double x= fabs(A.x - B.x);
	double y = fabs(A.y - B.y);
	return sqrt(x*x + y*y);
}


signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin>>n;
	for(int i = 1;i<=n;i++){
		cin>>a[i].x>>a[i].y;
	}
	double ans = 0x3f3f3f3f;
	for(int i = 1;i<n;i++){
		for(int j = i+1;j<=n;j++){
			ans = min(ans,dist(a[i],a[j]));
		}
	}
	cout<<fixed<<setprecision(4)<<ans;
	return 0;
}
原文