为什么控制台窗口不是水平而不是垂直打印数组内容?
有办法改变吗?
如何以水平方式而不是垂直方式显示数组内容Console.WriteLine()?
例如:
int[] numbers = new int[100]
for(int i; i < 100; i++)
{
numbers[i] = i;
}
for (int i; i < 100; i++)
{
Console.WriteLine(numbers[i]);
}
Run Code Online (Sandbox Code Playgroud) 未处理的异常:System.IndexOutOfRangeException:索引超出了数组的边界(在第一个if语句处)
static int arrayRows = 20;
static int arrayCols = 20;
public void printBoard()
{
int neighbours;
for (y = 0; y < arrayCols; y++)
for (x = 0; x < arrayRows; x++)
{
neighbours = 0;
// Count number of neighbours surrounding live cell
if (parentGen[x-1, y-1] == 1) // top left
neighbours++;
if (parentGen[x-1, y] == 1) // left
neighbours++;
if (parentGen[x-1, y+1] == 1) // bottom left
neighbours++;
if (parentGen[x, y-1] == 1) // middle top
neighbours++; …Run Code Online (Sandbox Code Playgroud)