随机产生50~100间的整数组成一个4行4列的矩阵,并求矩阵对角线元素的和.Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim a() As Integer, i, j, sum As Integer R
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/26 13:28:51
随机产生50~100间的整数组成一个4行4列的矩阵,并求矩阵对角线元素的和.Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim a() As Integer, i, j, sum As Integer R
随机产生50~100间的整数组成一个4行4列的矩阵,并求矩阵对角线元素的和.
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim a() As Integer, i, j, sum As Integer
ReDim ①
Label1.Text = "" : Label2.Text = ""
For i = 0 To 3
For j = 0 To 3
a(i, j) = ②
Label1.Text &= CStr(a(i, j)) & Space(5 - Len(CStr(a(i, j))))
If ③ Then sum += ④
Next
Label1.Text = ⑤
Next
Label2.Text = "对角线之和为:" & sum
End Sub
Private Sub Form1_Load(……) Handles Me.Load
Randomize( )
End Sub
随机产生50~100间的整数组成一个4行4列的矩阵,并求矩阵对角线元素的和.Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim a() As Integer, i, j, sum As Integer R
ReDim a(3,3) '①
a(i,j) = Int(Rnd() * 51 + 50) '②
If i = j Then sum += a(i,j) '③④
Label1.Text = Label1.Text & vbCrLf '⑤