求完整代码,下面是部分算法int ClosePoints(int x[], int y[], int n){ int index1, index2; int d, minDist = 10000; for (int i = 0; i<n - 1; i++) for (int j = i + 1; j <= n - 1; j++) { d = (x[i] - x[j])*(x[i] - x[j]) + (y[i] - y[j])*(y[i] - y[j]); if (d <= minDist) { minDist = d; index1 = i; index2 = j; } } cout << "最近的点对是:" << index1 << "和" << index2<< endl; return minDist;}
目前暂无任何回答
- 0 回答
- 0 关注
- 1641 浏览
添加回答
举报
0/150
提交
取消