参考答案:
<!DOCTYPE html><html><head lang="en"> <meta charset="UTF-8"> <title></title></head><body> <script> var N = 50; var m = 3; var array = []; for (var i = 0; i < N; i++) { array[i] = i + 1; } loop(array, []); function loop(arr1, arr2) { var before = arr1.concat(arr2); var after = []; for (var i = ((arr2.length == 0) ? 0 : arr1.length); i < before.length; i++) { if ((i + 1) % m != 0) { after.push(before[i]); } } if (after.length < 2) { console.log("在原来的位置是: " + after.join()); } else { loop(before, after); } } </script></body></html> 在原来的位置是: 11
时间: 2024-10-29 14:34:23