function test(){ var a = new Array(1, 3, 4, 6); var b = new Array(2, 7, 2, 1); var c = new Array(4, 1, 3, 3); var d = new Array(a, b, c); var e = new Array(); for (var i = 0; i < d.length; i++) { var f = new Array(); for (var j = 0; j < d.length; j++) { f[j] = pfc(d[i], d[j]); } e[i] = f; } console.log(e); } function pfc(arr1, arr2) { var re = 0; for (var i = 0; i < arr1.length; i++) { re += Math.pow((arr1[i] - arr2[i]), 2); } return Math.sqrt(re); }
12-06
831