📄 closestpair2.java
字号:
package firstproblem;
/**
* 求最近点对算法,使用这个类求得的复杂度为O(n^2)
* @author 何腾飞
*
*/
public class ClosestPair2 {
static double best = Double.MAX_VALUE;
static double temp;
static Pair pair = null;
public static Pair cpair(Point1 []p){
for(int i=0;i<p.length;i++){
for(int j=i+1;j<p.length;j++){
temp = Distance.dist(p[i], p[j]);
if(temp<best){
best = temp;
pair = new Pair(p[i],p[j],temp);
}
}
}
return pair;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -