【发布时间】:2020-12-01 00:21:31
【问题描述】:
从用户那里取笛卡尔坐标系(P0,P1,P2,P3,P4)中5个点的X和Y坐标,放到一个数组中(不是两个数组,肯定是一个数组)我想编写一个程序,将其放入二维欧几里德距离数组中,如下所示。
Array of coordinates (vector with 10 elements)
X0 Y0 X1 Y1 X2 Y2 X3 Y3 X4 Y4
Euclidean distance array (matrix in 5x5 form)
P1 -> P0 Distance
P2 -> P0 Distance P2 -> P1 Distance
P3 -> P0 Distance P3 -> P1 Distance P3 -> P2 Distance
P4 -> P0 Distance P4 -> P1 Distance P4 -> P2 Distance P4 -> P3 Distance
对于数字 1 到 10,我只是得到这个打印输出。
1 2 3 4 5 6 7 8 9 10
我的代码
#include <stdio.h>
#include <conio.h>
#include <math.h>
int main() {
int k[5][2],s[5][2];
int i=0,j=0,p=0,z=0,x1,x2,y1,y2;
for(i=0;i<5;i++){
for(j=0;j<2;j++){
printf("enter coordinates");
scanf("%d",&k[i][j]);
}
}
for(i=0;i<5;i++){
for(j=0;j<2;j++){
printf("%d\t",k[i][j]);
}
}
return 0;
}
【问题讨论】:
-
是的,相似度差不多,但我还是不知道怎么用我最后说的方式打印出来,所以是5 X 5矩阵。
标签: c