编辑代码
带有我要反转的行的文本文件包含这些数字:
1 2 3 4 5 6 7 8 9 10
11 12 13 14 15 16 17 18 19 20
21 22 23 24 25 26 27 28 29 30
31 32 33 34 35 36 37 38 39 40
41 42 43 44 45 46 47 48 49 50
51 52 53 54 55 56 57 58 59 60
61 62 63 64 65 66 67 68 69 70
71 72 73 74 75 76 77 78 79 80
81 82 83 84 85 86 87 88 89 90
91 92 93 94 95 96 97 98 99 100
到目前为止,我的数组看起来像这样:
static void Main()
{
int numbers;
StreamReader fileReader = new StreamReader(fileDirectory);
string line = fileReader.ReadLine();
fileReader.Close();
string[] Split = line.Split();
int.TryParse(line, out numbers);
int[,] Table = new int [10,10];
for (int row = 0; row < Table.GetUpperBound(0); row++)
{
for (int column = 0; column < Table.GetUpperBound(0); column++)
{
}
}
for (int row = 0; row < Table.GetUpperBound(0); row++)
{
for (int column = 0; column < Table.GetUpperBound(0); column++)
{
int tempHolder = Table[row, column];
Table[row, column] = Table.GetUpperBound(0);
Table[row, Table.GetUpperBound(0) - column] = tempHolder;
Console.WriteLine(Table[row, column]);
Console.Write(" ");
}
Console.WriteLine();
}Console.Write(" ");
}
你能帮我将 int numbers 变量添加到数组中,然后我将尝试反转。现在,如果我运行它,我会得到大约 24 行的数字 9。还有人可以告诉我如何做一个 2d 数组而不必指定它的大小吗?我在网上看过,但不知道怎么做。谢谢