题目:
思路:
arr[i][j] = arr[i][j - 1] + j + 1 + i
找到规律即可
提交:
while(line = readline()) {
let arr = new Array(Number(line)).fill([])
for(let i = 0; i < Number(line); i++) {
arr[i] = new Array(Number(line)).fill('')
if (i === 0) {
arr[i][0] = 1
} else {
arr[i][0] = arr[i - 1][0] + i
}
for(let j = 1; j < Number(line) - i; j++) {
arr[i][j] = arr[i][j - 1] + j + 1 + i
}
}
arr.forEach(item => {
console.log(item.join(' '))
})
}