-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram3.cs
More file actions
39 lines (37 loc) · 869 Bytes
/
Program3.cs
File metadata and controls
39 lines (37 loc) · 869 Bytes
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
Console.Write("Введите размерность m массива: ");
int m = Convert.ToInt32(Console.ReadLine());
Console.Write("Введите размерность n массива: ");
int n = Convert.ToInt32(Console.ReadLine());
int[,] randomArray = new int[m,n];
void mas(int m, int n)
{
int i,j;
Random rand = new Random();
for (i = 0; i < m; i++)
{
Console.WriteLine();
for (j = 0; j < n; j++)
{
randomArray[i,j] = rand.Next(1,9);
Console.Write($"{randomArray[i,j]} ");
}
Console.WriteLine();
}
}
void arif(int m, int n)
{
Console.Write("Среднее арифметическое каждого столбца: ");
int i,j;
Random rand = new Random();
for (j = 0; j < n; j++)
{
double sum = 0;
for (i = 0; i < m; i++)
{
sum = sum + randomArray[i,j];
}
Console.Write($"{sum/(i):F1}; ");
}
}
mas(m,n);
arif(m,n);