-1
我想在交錯數組來填充隨機數,但我在這行收到錯誤:在陣列填充隨機數字:ERROR:不能隱式int類型爲int []
arr[size] = randNum.Next(Min, Max);
ERROR :不能隱式int類型爲int []
這裏是全碼:
Random randNum = new Random();
int Min = 1;
int Max = 100;
int rows;
int size;
Console.WriteLine("Enter the number of rows of jagged array:");
rows = int.Parse(Console.ReadLine());
// Declare the array of two elements:
int[][] arr = new int[rows][];
for (int i = 0; i <= rows; i++)
{
Console.WriteLine("Enter the size of" +rows +" :");
size = int.Parse(Console.ReadLine());
for (int j = 0; j <= size; j++)
{
arr[j] = new int[size];
int n = 0;
while (n < size)
{
arr[size] = randNum.Next(Min, Max);
}
}
}
可以在這方面的任何一個幫助嗎?
_arr [i] [n] = randNum.Next(Min,Max); n ++ _ – Steve