题解 | #蛇形矩阵#
蛇形矩阵
http://www.nowcoder.com/practice/649b210ef44446e3b1cd1be6fa4cab5e
let num = parseInt(readline());
let arr = [];
let len = arr.length;
while(num>len){
let child=[]
if(len===0){
child=[1]
}else{
child=[arr[len-1][0]+len]
}
for(let i=len,j=0;i<num-1;i++,j++){
child.push(child[j]+i+2)
}
len+=1
arr.push(child)
}
arr.forEach(item=>{
console.log(item.join(' '))
})