OpenJudge

2:Distance sorting

总时间限制:
1000ms
内存限制:
65536kB
描述

Give you n (n <= 10) points in 3D space, please compute distances of every two points and sort the distances from far to near.

输入
First line contain a integer n indicating the number of points.
Second line contain the coordinates of the points. The coordinates are integers, from 0 to 100 inclusive. There are no two points in the same position.
输出
Output n*(n-1)/2 lines as follow:
(x1,y1,z1)-(x2,y2,z2)=Distance
样例输入
4
0 0 0 1 0 0 1 1 0 1 1 1
样例输出
(0,0,0)-(1,1,1)=1.73
(0,0,0)-(1,1,0)=1.41
(1,0,0)-(1,1,1)=1.41
(0,0,0)-(1,0,0)=1.00
(1,0,0)-(1,1,0)=1.00
(1,1,0)-(1,1,1)=1.00
提示
Distance keeps two decimal places. (You may use cout<(x1,y1,z1) appears before (x2,y2,z2) in the input data.
If two distances are equal, output the distance with the earlier pair of points firstly. A pair of points (x1, y1, z1) (x2, y2, z2) is earlier than another pair of points (x3, y3, z3) (x4, y4, z4) if and only if (x1, y1, z1) appears before (x3, y3, z3) in the input data OR (x1, y1, z1) equals (x3, y3, z3) and (x2, y2, z2) appears before (x4, y4, z4) in the input data.
全局题号
2703
提交次数
15
尝试人数
4
通过人数
2

Other language verions