import numpy as np # 例题:如何求解距离矩阵 demo_arr = np.empty((10, 10)) for i in range(10): demo_arr[i] = np.arange(i, i + 10) print(demo_arr[:10, :10]) a = ['一', '二'] b = ['横', '纵'] ls = [] for i in a: for j in b: c = eval(input("请输入第{}个数字{}坐标:".format(i, j))) ls.append(c) a = ls[0] b = ls[1] c = ls[2] d = ls[3] s = np.sqrt((c - a) ** 2 + (d - b) ** 2) print(s)
运行结果:
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)