-
Notifications
You must be signed in to change notification settings - Fork 0
/
Program.cs
49 lines (41 loc) · 1.11 KB
/
Program.cs
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
Console.WriteLine("Введите количество строк:");
int n = Convert.ToInt32(Console.ReadLine());
Console.WriteLine("Введите количество столбцов:");
int m = Convert.ToInt32(Console.ReadLine());
int[,] numbers = new int[n, m];
FillArrayRandomNumbers(numbers);
for (int j = 0; j < numbers.GetLength(1); j++)
{
double avarage = 0;
for (int i = 0; i < numbers.GetLength(0); i++)
{
avarage = (avarage + numbers[i, j]);
}
avarage = avarage / n;
Console.Write(avarage + "; ");
}
Console.WriteLine();
PrintArray(numbers);
void FillArrayRandomNumbers(int[,] array)
{
for (int i = 0; i < array.GetLength(0); i++)
{
for (int j = 0; j < array.GetLength(1); j++)
{
array[i, j] = new Random().Next(0, 10);
}
}
}
void PrintArray(int[,] array)
{
for (int i = 0; i < array.GetLength(0); i++)
{
Console.Write("[ ");
for (int j = 0; j < array.GetLength(1); j++)
{
Console.Write(array[i, j] + " ");
}
Console.Write("]");
Console.WriteLine("");
}
}