Top.Mail.Ru
Ответы

Помогите Исправить код Visual Basic .Говорит что переменные уже объявлены в блоке

Console.WriteLine("Задать квадратную матрицу, найти наибольший по модулю элемент и путем отбрасывания строки и столбца получить квадратную матрицу")
Console.Write("Введите размерность матрицы N=")
Dim N As Integer = Integer.Parse(Console.ReadLine())
Dim M As Integer(,) = New Integer(N, N) {}
Dim h As New Random()
Dim i As Integer = 0
While i <= N - 1
Dim j As Integer = 0
While j <= N - 1
M(i, j) = h.[Next](100)
System.Math.Max(System.Threading.Interlocked.Increment(j),j - 1)
End While
System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While
Dim i As Integer = 0
While i <= N - 1
Dim j As Integer = 0
While j <= N - 1
Console.Write("{0,5}", M(i, j))
System.Math.Max(System.Threading.Interlocked.Increment(j),j - 1)
End While
Console.WriteLine()
System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While
Dim max As Integer = 0
Dim m As Integer = 0
Dim n As Integer = 0
Dim i As Integer = 0
While i <= N - 1
Dim j As Integer = 0
While j <= N - 1
If M(i, j) > max Then
max = M(i, j)
m = i
n = j
End If
System.Math.Max(System.Threading.Interlocked.Increment(j),j - 1)
End While
System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While
Console.WriteLine("Число {0} наибольшее и имеет координаты {1},{2}", M(m, n), m, n)
Dim A As Integer(,) = New Integer(N - 1, N - 1) {}
Dim z As Integer = 0
Dim p As Integer = 0
Dim i As Integer = 0
While i < N
If i <> m Then
Dim j As Integer = 0
While j < N
If j <> n Then
A(p, z) = M(i, j)
System.Math.Max(System.Threading.Interlocked.Increment(z),z - 1)
End If
System.Math.Max(System.Threading.Interlocked.Increment(j),j - 1)
End While
System.Math.Max(System.Threading.Interlocked.Increment(p),p - 1)
z = 0
End If
System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While
Dim i As Integer = 0
While i < N - 1
Dim j As Integer = 0
While j < N - 1
Console.Write("{0,5}", A(i, j))
System.Math.Max(System.Threading.Interlocked.Increment(j),j - 1)
End While
Console.WriteLine()
System.Math.Max(System.Threading.Interlocked.Increment(i),i - 1)
End While
Console.ReadKey()

По дате
По рейтингу
Аватар пользователя
Искусственный Интеллект
9лет

Вы что думаете что все присвоения делаются перо помощи DIM? Это не так...

Аватар пользователя
Искусственный Интеллект
9лет

Ну так да, выше объявлены уже, удалите эти строки и всё