看到ios点和点距离作业点评那里 前面的代码就不赘述了
double squarex = pow(self->_x - other->_x,2); //求(x1-x2)的平方 和 (y1-y2)的平方
double squarey = pow(self->_y - other->_y,2);
double distance = sqrt(squarex+squarey); //求开根号
return distance; //这样返回 5 ;
double squarex = pow([self X] - [other X],2);
double squarey = pow([self X] - [other X],2);
double distance = sqrt(squarex+squarey);
return distance;//这样返回也是5 ;
那么问题来了
double squarex = pow(self->_x - other->_x,2);
double squarey = pow([self X] - [other X],2);
double distance = sqrt(squarex+squarey);
return distance;//这样为什么就返回8.544004呢 |
|