给定三角形 3 条边的长度,计算边中点之间的平均距离

Given lengths of 3 sides of a triangle, compute an average distance between the middle points of the sides

我遇到了一个问题。问题陈述是

一队3人,将要参加一场比赛。根据本次比赛的规定,每队发一台电脑,电脑位于三角table上,三把椅子.

团队认为参与者最方便的位置是 三个参与者中的每一个坐在三角形 table 的 his/her 自己的一侧,而且,重要的是, 正好在这一边的中间。 当然椅子也应该这样放。

重要的是,在比赛期间,参赛者之间的坐姿不要太远。梦之队队长认为,对这个因素的正确估计是所有这些参与者之间的平均距离。

在本次比赛中,参赛者必须计算三角形各边中点之间的平均距离table。编写一个程序来计算这个。 Note that the distance is Euclidean – that is, the distance between (x1,y1) and (x2,y2) is sqrt((x_1 - x_2)^2 + (y_1 - y_2)^2).

输入

输入文件包含三个不超过100的正整数——table的边长。 保证这样的table会有一个非零区域

输出

输出table两边中点之间的平均距离,这在输入中有描述。

Examples  
Input        Output
3 4 5        2.00000000
5 5 7        2.83333333

我想到了一个方法来解决这个问题

1. Assume origin as 1 point.
2. If one of the length is 3, assume the point as (3,0).
3. Now, I struck at finding 3rd coordinate

我的做法好吗?

请给我一个算法来解决这个问题。

谢谢

注意连接边A中点和边B中点的线段为half of edge C,其他边同理。

所以解决方案非常简单 - 边长为 A、B、C 的三角形的平均距离为

M = (A/2 + B/2 + C/2) / 3 = 
    (A + B + C ) / 6