3个回答
展开全部
Private Sub Command1_Click()
Const A As Long = 5
Dim i As Long, j As Long, k As Long
Dim S As String
For i = 1 To A
S = ""
For j = 1 To A
If j = i Or j = A - i + 1 Then
S = S & "1"
Else
S = S & "0"
End If
Next j
Print S
Next i
End Sub
Const A As Long = 5
Dim i As Long, j As Long, k As Long
Dim S As String
For i = 1 To A
S = ""
For j = 1 To A
If j = i Or j = A - i + 1 Then
S = S & "1"
Else
S = S & "0"
End If
Next j
Print S
Next i
End Sub
追问
可不可以解释一下怎么想的呢?
追答
If j = i Or j = A - i + 1 Then,主要就是这一句,当行数和列数相等时就是左上角到右下角的那些1,当行数加列数等于A+1时就是右上角到左下角那些1,这样就把所有的1都包括在内了。
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询