Sub Main
Dim n&, arr&, tmp&, s$
n = InputBox("Введите размерность матрицы")
ReDim arr(1 to n, 1 to n)
for i = 1 to n
for j = 1 to n
tmp = iif(i = j, 2,j)
arr(i,j) = tmp
next
next
for i = 1 to n
for j = 1 to n
s = s & arr(i,j) & " "
next
s = s & chr(13)
next
MsgBox(s)
End Sub