using System using System Collections Generic using System Linq using

 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
int i, j, k, q;
int[,] matrix = new int[7, 5];
int[] mas = new int[matrix.GetLength(0)];
int[] mas2 = new int[matrix.GetLength(0)];
Random rand = new Random();
int min = 0;
Console.WriteLine("Есть матрица:");
for (i = 0; i < matrix.GetLength(0); i++)
{
for (j = 0; j < matrix.GetLength(1); j++)
{
matrix[i, j] = rand.Next(1, 9);
Console.Write(matrix[i, j] + " ");
}
Console.WriteLine();
}
Console.WriteLine("Здесь строки по порядку:");
for (i = 0; i < 7; i++)
{
min = matrix[i, 0];
for (q = 0; q < 5; q++)
{
if (min > matrix[i, q])
min = matrix[i, q];
}
mas[i] = min;
}
for (i = 0; i < 6; ++i)
{
min = i;
for (j = i + 1; j < 7; ++j)
if (mas[min] > mas[j])
min = j;
if (min != i)
{
int r;
r = mas[i];
mas[i] = mas[min];
mas[min] = r;
for (k = 0; k < 5; k++)
{
r = matrix[i, k];
matrix[i, k] = matrix[min, k];
matrix[min, k] = r;
}
}
}
Console.WriteLine();
for (i = 0; i < matrix.GetLength(0); i++)
{
for (j = 0; j < matrix.GetLength(1); j++)
{
Console.Write(matrix[i, j] + " ");
}
Console.WriteLine();
}
}
}
}