急用!!女朋友急着要我帮忙解决,大家救命了
急用!!!!!想了半天,就不知道怎么填了,其它的方法到想到好多种
希望大家帮帮忙了
以下程序代码使用二维叔祖A表示矩阵,实现单击命令按钮COMMAND时,使矩阵的两条对角线上的元素值全为0,其他全为1,填空补充完整
Dim A(1 To 4, 1 To 4)
For i = 1 To 4
For j = 1 To 4
A( ) = 0
Next j
A( ) = 1
A( ) = 1
Next i
For i = 1 To 4
For j = 1 To 4
MsgBox A(i, j)
Next j
Next i
End Sub
请加上你的讲解
[解决办法]
Dim A(1 To 4, 1 To 4)
Dim i As Integer, j As Integer
For i = 1 To 4
For j = 1 To 4
A(i, j) = 0
Next j
A(i, (6 - i) Mod 4 + 1) = 1
A(i, 4 - (6 - i) Mod 4) = 1
Next i
For i = 1 To 4
For j = 1 To 4
Print A(i, j);
Next j
Print
Next i
[解决办法]
或者这样也可以
Private Sub Command1_Click()
Dim A(1 To 4, 1 To 4)
For i = 1 To 4
For j = 1 To 4
A(i, j) = 0
Next j
A(i, 2 - (Int(i / 2) Mod 2)) = 1
A(i, 3 + (Int(i / 2) Mod 2)) = 1
Next i
For i = 1 To 4
For j = 1 To 4
Print A(i, j),
Next j
Print
Next i
End Sub
[解决办法]
Private Sub Command1_Click()
Dim A(1 To 4, 1 To 4)
For i = 1 To 4
For j = 1 To 4
if i=j or i+j=5 then
A(i, j) = 0
else
A(i, j) = 1
endif
Next j
Next i
For i = 1 To 4
For j = 1 To 4
Print A(i, j),
Next j
Print
Next i
End Sub
[解决办法]
不好意思,打错了。
Dim A(1 To 4, 1 To 4), i, j
For i = 1 To 4
For j = 1 To 4
A(i, j) = 0
Next j
A(i, i) = 1
A(i, 5 - i) = 1
Next i
For i = 1 To 4
For j = 1 To 4
Debug.Print A(i, j);
Next j
Debug.Print
Next i