Unity 二维数组的转置

xiaoxiao2021-02-28  91

int[,] arr = new int[3, 4] { { 1, 2, 3, 4 }, { 5, 6, 7, 8 }, { 9, 10, 11, 12 } }; int x = arr.GetLength(0); int y = arr.GetLength(1); int[,] arrNew = new int[y,x]; print("X为" + x + "Y为" + y); for (int i = 0; i < x; i++) { for (int j = 0; j < y; j++) { arrNew[j, i] = arr[i, j]; print(arrNew[j, i]); } }
转载请注明原文地址: https://www.6miu.com/read-51845.html

最新回复(0)