题意是求出所给各点中最近点对的距离的一半(背景忽略). 用分治的思想,先根据各点的横坐标进行排序,以中间的点为界,分别求出左边点集的最小距离和右边点集的最小距离,然后开始合并,分别求左右点集中各点与中间点的距离,从这些距离与点集中的最小距离比较,求得最小距离,此处可按纵坐标排序,将纵坐标距离已经大于之前最小距离的部分都剪枝. 代码如下: #include <bits/stdc++.h> using namespace std; ]; struct point { double x,y; }p[…