| 5 | 1/1 | 返回列表 |
| 查看: 2264 | 回復: 7 | |||
| 當前只顯示滿足指定條件的回帖,點擊這里查看本話題的所有回帖 | |||
[交流]
【求助】求算法,兩點間距離問題
|
|||
|
求算法: 平面上有很多點,每個點的坐標x,y已知。求相鄰兩點距離最大的值。 點大概如下分布 。 。 。 。 。 。。。 。 。。 。。 。 。 。。 。 。 。 。 。 。 。 。 。 。 。。 。。。 。 。。。 上下也算相鄰,左右也算相鄰。不是求所有這些點中距離最大的那兩點,而是相鄰的這么多距離最大的那個距離。 |
» 搶金幣啦!回帖就可以得到:
+1/182
+1/89
+1/87
+2/80
+1/38
+1/35
+1/35
+5/25
+1/18
+1/11
+1/11
+1/9
+1/9
+1/9
+1/7
+1/5
+1/4
+2/2
+1/2
+1/1
|
#include #include #define ROWS 2 #define COLS 2 typedef struct { double x; double y; }POINT; void main() { POINT coords[ROWS][COLS]; int i,j; double dis,max=0; for(i=0;i for(i=0;i if (j dis=sqrt((coords[j].x-coords[j+1].x)*(coords[j].x-coords[j+1].x)+(coords[j].y-coords[j+1].y)*(coords[j].y-coords[j+1].y)); if (dis>max) max=dis; } if (i dis=sqrt((coords[j].x-coords[i+1][j].x)*(coords[j].x-coords[i+1][j].x)+(coords[j].y-coords[i+1][j].y)*(coords[j].y-coords[i+1][j].y)); if (dis>max) max=dis; } } cout<<"the maximum distance is "< |
| 最具人氣熱帖推薦 [查看全部] | 作者 | 回/看 | 最后發(fā)表 | |
|---|---|---|---|---|
|
[考研] 張芳銘-中國農(nóng)業(yè)大學-環(huán)境工程專碩-298 +8 | 手機用戶 2026-03-26 | 8/400 |
|
|---|---|---|---|---|
|
[考研] 315求調(diào)劑 +5 | akie... 2026-03-28 | 6/300 |
|
|
[考研] 南京大學化學調(diào)劑 +11 | 景隨風 2026-03-29 | 16/800 |
|
|
[考研] 266求調(diào)劑 +3 | 哇呼哼呼哼 2026-03-29 | 3/150 |
|
|
[考研] 282求調(diào)劑 +3 | 呼吸都是減肥 2026-03-31 | 3/150 |
|
|
[考研] 279求調(diào)劑 +12 | j的立方 2026-03-29 | 12/600 |
|
|
[考研] 一志愿華中師范化學332分求調(diào)劑 +3 | Lyy930824@ 2026-03-29 | 3/150 |
|
|
[考研] 289求調(diào)劑 +16 | 新時代材料 2026-03-27 | 16/800 |
|
|
[考研] 324求調(diào)劑 +9 | hanamiko 2026-03-26 | 11/550 |
|
|
[考研] 327求調(diào)劑 +6 | 汲亦昊 2026-03-29 | 6/300 |
|
|
[考研] 0856求調(diào)劑 +13 | zhn03 2026-03-25 | 14/700 |
|
|
[考研] 一志愿華理,數(shù)一英一285求A區(qū)調(diào)劑 +8 | AZMK 2026-03-25 | 12/600 |
|
|
[考研] 材料277求調(diào)劑 +7 | min3 2026-03-24 | 7/350 |
|
|
[考研] 275求調(diào)劑 +10 | jjjjjjjjjjl 2026-03-27 | 10/500 |
|
|
[考研] 086000調(diào)劑 +3 | 7901117076 2026-03-26 | 3/150 |
|
|
[考研] 266求調(diào)劑 +11 | 陽陽哇塞 2026-03-27 | 12/600 |
|
|
[考研] 266分求材料化工冶金礦業(yè)等專業(yè)的調(diào)劑 +4 | 哇呼哼呼哼 2026-03-26 | 4/200 |
|
|
[考研]
|
18419759900 2026-03-25 | 8/400 |
|
|
[考研] 336材料求調(diào)劑 +7 | 陳瀅瑩 2026-03-26 | 9/450 |
|
|
[考研] 085601求調(diào)劑總分293英一數(shù)二 +4 | 鋼鐵大炮 2026-03-24 | 4/200 |
|