class Program {
static void Main(string[] args) {
int row = 10;
int col = 8;
// 因爲x是橫向座標,所以代表的應該是列,y則代表行,而寫左邊時習慣爲x,y 所以定義二維數組時應該爲[列,行]
int[,] map = new int[col, row];
int x = 2, y = 3;
map[x, y] = 6;
// 遍歷行
for (int j = 0; j < map.GetLength(1); j++) {
// 遍歷列各字符,連接成行
for (int i = 0; i < map.GetLength(0); i++) {
Console.Write(map[i,j].ToString().PadRight(4));
}
// 換行
Console.WriteLine();
}
}
}
static void Main(string[] args) {
int row = 10;
int col = 8;
// 因爲x是橫向座標,所以代表的應該是列,y則代表行,而寫左邊時習慣爲x,y 所以定義二維數組時應該爲[列,行]
int[,] map = new int[col, row];
int x = 2, y = 3;
map[x, y] = 6;
// 遍歷行
for (int j = 0; j < map.GetLength(1); j++) {
// 遍歷列各字符,連接成行
for (int i = 0; i < map.GetLength(0); i++) {
Console.Write(map[i,j].ToString().PadRight(4));
}
// 換行
Console.WriteLine();
}
}
}