VB 麻烦把A矩阵改成下三角型显示,B上三角型显示

PrivateSubCommand1_Click()Dima(4,4)AsIntegerDimiAsInteger,jAsIntegerFori=1To4Forj=1To... Private Sub Command1_Click()
Dim a(4, 4) As Integer
Dim i As Integer, j As Integer
For i = 1 To 4
For j = 1 To 4
a(i, j) = Int(Rnd * 41 + 30)
Print a(i, j);
Next j
Print
Next i
Print
Dim b(4, 4) As Integer
For i = 1 To 4
For j = 1 To 4
b(i, j) = Int(Rnd * 34 + 101)
Print b(i, j);
Next j
Print
Next i
展开
 我来答
jx41114
2011-04-27
知道答主
回答量:5
采纳率:0%
帮助的人:10.6万
展开全部
Private Sub Command1_Click()
Dim a(4, 4) As Integer
Dim i As Integer, j As Integer
For i = 1 To 4
For j = i To 4
a(i, j) = Int(Rnd * 41 + 30)
Print a(i, j);
Next j
Print
Next i
Print
Dim b(4, 4) As Integer
For i = 1 To 4
For j = 1 To i
b(i, j) = Int(Rnd * 34 + 101)
Print b(i, j);
Next j
Print
Next i
End Sub
或者将程序写成下面的形式,用空格占位,使A的数据输出位置更加直观
Private Sub Command1_Click()
Dim a(4, 4) As Integer
Dim i As Integer, j As Integer
For i = 1 To 4
For j = 1 To i - 1 '输出空格使数字在上三角的位置上
Print Spc(4);
Next j
For j = i To 4
a(i, j) = Int(Rnd * 41 + 30)
Print a(i, j);
Next j
Print
Next i
Print
Dim b(4, 4) As Integer
For i = 1 To 4
For j = 1 To i
b(i, j) = Int(Rnd * 34 + 101)
Print b(i, j);
Next j
Print
Next i
End Sub
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式