题解 | 两点间距离

两点间距离

https://www.nowcoder.com/practice/94712d6f654143379f8ea5847d9d6225

题干解读:给出两个点数据,要求他们之间的举例

解题思路:直接使用点到点之间的举例公式即可.

/**
 * struct Point {
 *	int x;
 *	int y;
 *	Point(int xx, int yy) : x(xx), y(yy) {}
 * };
 */
class Solution {
public:
    /**
     * 代码中的类名、方法名、参数名已经指定,请勿修改,直接返回方法规定的值即可
     *
     * 计算A点与B点之间的距离
     * @param point_A Point类 A点
     * @param point_B Point类 B点
     * @return double浮点型
     */
    double calculateDistance(Point point_A, Point point_B) {
        double dis;
        dis = sqrt((point_A.x-point_B.x)*(point_A.x-point_B.x)+(point_A.y-point_B.y)*(point_A.y-point_B.y));
        return dis;
    }
};

全部评论

相关推荐

码农索隆:以下是我以我微薄的认知提供的建议: 1.考个教师资格证,去当体育考试。 2.去健身房当健身教练(因为在我印象里面体育生身材都不错)。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务