用vb程序设计输出一个右上三角元素(含对角线)为1,其余元素为0 的5×5矩阵。
1个回答
展开全部
Dim a(5, 5)
Private Sub Command1_Click()
'右,倒三角形
For i = 0 To 4
For j = 0 To 4
If j >= i Then
a(i, j) = 1
Else
a(i, j) = 0
End If
Print a(i, j),
Next j
Print
Next i
End Sub
Private Sub Command2_Click()
'右,三角形
For i = 0 To 4
For j = 0 To 4
If 4 - j <= i Then
a(i, j) = 1
Else
a(i, j) = 0
End If
Print a(i, j),
Next j
Print
Next i
End Sub
Private Sub Command1_Click()
'右,倒三角形
For i = 0 To 4
For j = 0 To 4
If j >= i Then
a(i, j) = 1
Else
a(i, j) = 0
End If
Print a(i, j),
Next j
Next i
End Sub
Private Sub Command2_Click()
'右,三角形
For i = 0 To 4
For j = 0 To 4
If 4 - j <= i Then
a(i, j) = 1
Else
a(i, j) = 0
End If
Print a(i, j),
Next j
Next i
End Sub
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询