随机矩阵vb.net 随机矩阵怎么建立matlab
Vb随机矩阵小问题
Private
成都创新互联凭借在网站建设、网站推广领域领先的技术能力和多年的行业经验,为客户提供超值的营销型网站建设服务,我们始终认为:好的营销型网站就是好的业务员。我们已成功为企业单位、个人等客户提供了成都网站设计、成都做网站服务,以良好的商业信誉,完善的服务及深厚的技术力量处于同行领先地位。
Sub
Command1_Click()
Dim
a(4,
4)
As
Integer,
b(4,
4)
As
Integer,
c(4,
4)
As
Single,
s
As
Long,
d(16)
As
Integer
m1%
=
1:
m2%
=
1:
l1%
=
1:
l2%
=
1
Randomize
For
i
=
1
To
4
For
t
=
1
To
4
a(i,
t)
=
Int(Rnd(1)
*
9
+
1)
If
i
=
t
Or
i
+
t
=
5
Then
s
=
s
+
a(i,
t)
'对角线元素值累加
d(i
+
(t
-
1)
*
4)
=
a(i,
t)
'按列放入D
b(i,
t)
=
Int(Rnd(1)
*
11
+
10)
c(i,
t)
=
a(i,
t)
*
b(i,
t)
'乘法
If
c(i,
t)
c(l1,
l2)
Then
l1
=
i:
l2
=
t
'求最大数组下标
If
c(i,
t)
c(m1,
m2)
Then
m1
=
i:
m2
=
t
'求最小数组下标
Next
Next
"最大值";
c(l1,
l2);
"下标";
l1;
",";
l2
"最小值";
c(m1,
m2);
"下标";
m1;
",";
m2
"A两条对角线平均值";
s
/
8
"D的结果为:";
'打印D
For
i
=
1
To
16
Str(d(i));
Next
End
Sub
vb.net矩阵的问题
要实现什么样的功能呢?矩阵就是二维表吧,在.Net中有许多方法可以实现二维表,根据不同的需求选择适合的方法,你应该详细一点说明
VB.NET的题目 利用随机数生成两个4*4的矩阵A~~紧急紧急
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
MsgBox(Int(Rnd() * 10))
Dim n As Integer = 4
Dim i, a As Integer
Dim r As String
Randomize()
For i = 1 To n
r = Int(Rnd() * 10)
Label1.Text = Space(n - i + 1) StrDup(i, r) + vbNewLine
Next i
For i = n To 1 Step -1
r = Int(Rnd() * 10)
Label1.Text = Space(n - i + 1) StrDup(i, r) + vbNewLine
Next i
For Each c In Label1.Text
If IsNumeric(c) Then
a += 1
End If
Next
MsgBox(a) ‘主对角线和次对角线上各元素之和
End Sub
另一个矩阵也是用同样方法.
你说的是不是这样?
分享文章:随机矩阵vb.net 随机矩阵怎么建立matlab
当前URL:http://azwzsj.com/article/hhdcis.html