P
I've been thinking long, but I think I've learned the challenge, and that's the solution:static void Main(string[] args)
{
int[][] myArray = new int[10][];
Random rndGenerator = new Random();
int count;
Console.Write("Введите число элементов массива: ");
while (!int.TryParse(Console.ReadLine(), out count) || count <= 0)
{
Console.Write("Неверный ввод, попробуйте еще раз: ");
}
for (int i = 0; i < myArray.Length; i++)
{
myArray[i] = new int[i < myArray.Length - 1 ? 10 : count % 10];
}
for (int i = 0; i < myArray.Length; i++)
{
for (int j = 0; j < myArray[i].Length; j++)
{
myArray[i][j] = rndGenerator.Next(-30, 45);
}
}
for (int i = 0; i < myArray.Length; i++)
{
for (int j = 0; j < myArray[i].Length; j++)
{
Console.Write(myArray[i][j].ToString().PadLeft(3, ' '));
if (j < myArray[i].Length - 1)
Console.Write(", ");
else
Console.WriteLine();
}
}
Console.ReadKey();
}
ConclusionВведите число элементов массива: 93
-1, 21, 14, -29, -14, -1, -22, 30, -27, -22
-22, 22, 32, 12, -24, 19, -16, 41, 23, -4
-10, -23, -2, -29, -23, 11, -7, 38, 23, 18
-13, -3, -10, 11, 20, 35, 5, 7, -2, -6
-30, 43, 16, -4, -8, 28, 32, 24, 12, -6
21, 1, 7, -9, -18, -8, -7, 12, 39, 20
-24, -15, -23, 0, 36, 26, 2, -10, 37, -15
-17, 22, 13, -1, -5, -9, 5, -29, 23, -7
23, 14, -5, -2, 42, 30, 34, 43, -1, -3
11, 38, 13