题解 | #蛇形矩阵# 【参考评论区】嵌套数组
蛇形矩阵
https://www.nowcoder.com/practice/649b210ef44446e3b1cd1be6fa4cab5e
const readline = require('readline'); const rl = readline.createInterface({ input: process.stdin, output: process.stdout }); rl.on('line', function (line) { const n = parseInt(line); let res = new Array(n).fill().map(item => Array()); let cur = 1; for(let i = 0; i < n; i++){ for(let j = i; j >= 0; j--){ res[j].push(cur); cur++; } } for(let line of res){ console.log(line.join(' ')); } });
#华为笔试#