O(n)级别的,一次遍历就完事,就是条件有点多 public class Solution { public int[][] generateMatrix(int n) { int num = n * n; int c = 0; int row = 1; int m = 1; int x = 0; int count = n; int[][] arr = new int[n][n]; for(int i = 1; i <= num; i++) { ...