用VB 6.0写下列程序,谢谢
用VB6.0写程序,谢谢1.利用随机函生成A和B两个矩阵,求A矩阵主对角线上的元素之和、求B矩阵副对角线上的元素之和。(实验5之5)2.输入整数n(1<=n<=8),显示...
用VB 6.0写程序,谢谢
1.利用随机函生成A和B两个矩阵,求A矩阵主对角线上的元素之和、求B矩阵副对角线上的元素之和。(实验5之5)
2.输入整数n(1<=n<=8),显示具有n 行的杨辉三角形。(实验5之6) 展开
1.利用随机函生成A和B两个矩阵,求A矩阵主对角线上的元素之和、求B矩阵副对角线上的元素之和。(实验5之5)
2.输入整数n(1<=n<=8),显示具有n 行的杨辉三角形。(实验5之6) 展开
展开全部
Private Sub Form_Click()
Dim a(2, 2) As Integer, b(2, 2) As Integer
Dim i As Integer, j As Integer
Dim n1 As Integer, n2 As Integer
For i = 0 To 2
For j = 0 To 2
a(i, j) = Int(Rnd * 10)
Print a(i, j); " ";
Next
Next
For i = 0 To 2
n1 = n1 + a(i, i)
Next
Print n1
For i = 0 To 2
For j = 0 To 2
b(i, j) 源察= Int(Rnd * 10)
Print b(i, j); "雹桥茄 ";
Next
Next
For i = 2 To 0 Step -1
n2 = n2 消消+ b(i, 2 - i)
Next
Print n2
End Sub
Private Sub Form_click()
Dim n As Integer, i As Integer
Dim j As Integer, k As Integer
n = Val(InputBox("", "", 5))
ReDim a(n + 1, n + 1), b(n + 1, n + 1)
Cls
k = 8
For i = 1 To n
Print String((n - i) * k / 2 + 1, " ");
For j = 1 To i
a(i, 1) = 1
a(i, i) = 1
a(i + 1, j + 1) = a(i, j) + a(i, j + 1)
b(i, j) = Trim(Str(a(i, j)))
Print b(i, j); String(k - Len(b(i, j)), " ");
Next j
Next i
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询