Как поменять местами соответствующие элементы главной и побочной диагоналей матрицы? Никак не могу найти свою ошибку..
Dim i As Integer, j As Integer, razmer As Integer
Dim znak As Integer, k As Integer
Dim a() As Integer, c As Integer
Randomize
razmer = Int(Rnd * 3) + 2
ReDim a(1 To razmer, 1 To razmer)
For i = 1 To razmer
For j = 1 To razmer
znak = Int(Rnd * 2)
a(i, j) = Int(Rnd * 9)
If stroka = "" Then
stroka = a(i, j)
Else
stroka = stroka & " " & a(i, j)
End If
Next
List1.AddItem stroka
stroka = ""
Next
k = razmer + 1
For i = 1 To razmer
For j = 1 To razmer
If i = j Then
c = a(i, j)
k = k - 1
a(i, j) = a(i, k)
a(i, k) = c
End If
stroka = stroka & " " & a(i, j)
Next
List2.AddItem stroka
stroka = ""
Next