User input into a two dimensional array

前端 未结 6 1762
生来不讨喜
生来不讨喜 2021-01-07 13:44

I\'m completely new to C# and well I would like simple code to create a matrix from user input

E.G.

int [,] matrix1 = new int [2,2]
// now using inpu         


        
6条回答
  •  北海茫月
    2021-01-07 14:25

    var numbers = new int[size, size];

                for (var i = 0; i < size; i++)
                {
                    var numList = new string[size];
                    numList = readLine.Split();
                    for (var j = 0; j < size; j++)
                    {
                        numbers[i, j] =convert.ToInt32(numList[j]);                        
                    }
    

    }

提交回复
热议问题