一个基本算法,标准的欧几里得距离
BCB写的 首先是include
#include <math.h>
#include <vector>
using
using std::vector;
struct
struct point{
public :
int X;
int Y;
};
struct p_result{
public :
point p1;
point p2;
};
全局
vector<point> loli;
正题:C_point函数
p_result C_point(void){
int i,j;
int dmin=10000;
double d;
int i1,i2;
int count;
count=XXXXXXXze();
point result;
point result2;
for (i = 0; i < count-1; i++) {
for (j = i+1; j < count; j++) {
int in1,in2;
in1=pow((loli[i].X-loli[j].X),2);
in2=pow((loli[i].Y-loli[j].Y),2);
d = sqrt(in1+in2);
if (d < dmin) {
dmin = d;
i1=i;
i2=j;
}
}
}
result.X = loli[i1].X;
result.Y = loli[i1].Y;
result2.X = loli[i2].X;
result2.Y = loli[i2].Y;
p_result re;
re.p1 = result;
re.p2 = result2;
return (re);
}
我自重……