![](https://iknow-base.cdn.bcebos.com/lxb/notice.png)
求写一个VB.Net小程序
要求:按《随机生成》按钮后在groupbox(关系矩阵)里面的label1里面显示一个随机矩阵(矩阵元素只包含0和1)如图label1可以换成textbox或者直接在gr...
要求:
按《随机生成》按钮后 在groupbox(关系矩阵)里面的label1 里面显示一个随机矩阵(矩阵元素只包含0和1)
如图
label1 可以换成textbox 或者 直接在groupbox里面显示也可以 展开
按《随机生成》按钮后 在groupbox(关系矩阵)里面的label1 里面显示一个随机矩阵(矩阵元素只包含0和1)
如图
label1 可以换成textbox 或者 直接在groupbox里面显示也可以 展开
1个回答
展开全部
随机生成2-5阶方阵:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim d(,) As Integer
Dim n As Integer
Dim i As Integer
Dim j As Integer
Randomize()
n = Int(4 * Rnd() + 2)
ReDim d(n, n)
Label1.Text = ""
For i = 1 To n
For j = 1 To n
d(i, j) = Int(Rnd() + 0.5)
Label1.Text = Label1.Text & d(i, j) & " "
Next
Label1.Text = Label1.Text & vbCrLf
Next
End Sub
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim d(,) As Integer
Dim n As Integer
Dim i As Integer
Dim j As Integer
Randomize()
n = Int(4 * Rnd() + 2)
ReDim d(n, n)
Label1.Text = ""
For i = 1 To n
For j = 1 To n
d(i, j) = Int(Rnd() + 0.5)
Label1.Text = Label1.Text & d(i, j) & " "
Next
Label1.Text = Label1.Text & vbCrLf
Next
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询