46. 三维坐标距离

单点时限: 1.0 sec

内存限制: 256 MB

定义函数 Distance,计算两个三维坐标点之间的距离。

#include <stdio.h>

typedef struct {
    int x, y, z;
} Point;

double Distance(Point a, Point b)
/* PreCondition:
     a,b 点的每维坐标值范围为 -100 ~ +100
   PostCondition:
     返回 a,b 点之间的距离
*/
{

}

int main() {
    Point a, b;
    scanf("%d%d%d", &a.x, &a.y, &a.z);
    scanf("%d%d%d", &b.x, &b.y, &b.z);
    printf("%.9f\n", Distance(a, b));
    return 0;
}

输出格式

提示:答案相对误差或绝对误差在 $10^{-6}$ 以内即可。

样例

Input
1 2 3
10 9 8
Output
12.449899598

344 人解决,364 人已尝试。

363 份提交通过,共有 590 份提交。

1.0 EMB 奖励。

创建: 6 年,4 月前.

修改: 6 年,4 月前.

最后提交: 2 月,3 周前.

来源: 2018 程序设计基础期末考

题目标签