func spiralArrayV(n int) [][]int{
// 得到1到n^2的螺旋正矩阵
// 模拟情形,统一边界遍历方式,均左闭右闭
dp := make([][]int, n)
for i, _ := range dp {
dp[i] = make([]int, n)
}
top, bottom := 0, n-1
left, right := 0, n-1
num := 1
for num <= n * n {
for i := left; i <= right; i++{
dp[top][i] = num
num++
}
top++
for i := top; i <= bottom; i++{
dp[i][right] = num
num++
}
right--
for i := right; i >= left; i--{
dp[bottom][i] = num
num++
}
bottom--
for i := bottom; i >= top; i--{
dp[i][left] = num
num++
}
left++
}
return dp
}
</