在程序设计语言里,用二维数组来保存矩阵的值.
一维列矩阵,就是由:若干行、一列组成的二维数组.
一维行矩阵,就是由:一行、若干列组成的二维数组.
比如一维列矩阵,的输入:
dim a(10,1) as integer '10行,1列
dim i as integer
for i = 1 to 10
a(i,1) = inputbox("")
next i
Public Shared Sub Main()
Dim a As Integer, b As Integer, c As Integer, d As Integer
Console.WriteLine("该程序将求出两个矩阵的积:")
Console.WriteLine("请指定矩阵A的行数:")
a = Integer.Parse(Console.ReadLine())
Console.WriteLine("请指定矩阵A的列数:")
b = Integer.Parse(Console.ReadLine())
Dim MatrixA As Integer(,) = New Integer(a - 1, b - 1) {}
For i As Integer = 0 To a - 1
For j As Integer = 0 To b - 1
Console.WriteLine("请输入矩阵A第{0}行第{1}列的值:", i + 1, j + 1)
MatrixA(i, j) = Integer.Parse(Console.ReadLine())
Next
Console.WriteLine("矩阵A输入完毕.")
Console.WriteLine("请指定矩阵B的行数:")
c = Integer.Parse(Console.ReadLine())
Console.WriteLine("请指定矩阵B的列数:")
d = Integer.Parse(Console.ReadLine())
Dim MatrixB As Integer(,) = New Integer(c - 1, d - 1) {}
For i As Integer = 0 To c - 1
For j As Integer = 0 To d - 1
MatrixB(i, j) = Integer.Parse(Console.ReadLine())
Console.WriteLine("矩阵B输入完毕.")
Console.WriteLine("矩阵A为:")
outputMatrix(MatrixA, a, b)
Console.WriteLine("矩阵B为:")
outputMatrix(MatrixB, c, d)
If b c Then
Console.WriteLine("矩阵A的列数与矩阵B的行数不相等,无法进行乘积运算!")
Return
Else
Console.WriteLine("矩阵A与矩阵B的乘积为:")
End If
Dim MatrixC As Integer(,) = New Integer(a - 1, d - 1) {}
MatrixC(i, j) = 0
For k As Integer = 0 To b - 1
MatrixC(i, j) += MatrixA(i, k) * MatrixB(k, j)
outputMatrix(MatrixC, a, d)
End Sub
Private Shared Sub outputMatrix(MatrixX As Integer(,), rowCount As Integer, columnCount As Integer)
For i As Integer = 0 To rowCount - 1
For j As Integer = 0 To columnCount - 1
Console.Write(MatrixX(i, j) vbTab)
Console.WriteLine()
End Class
Private Sub cmdCommand1_Click()
Me.AutoRedraw = True
Dim Grp
Dim i, j As Long
Dim StrPrt As String
For i = 0 To UBound(Grp)
'i为位移量
StrPrt = ""
For j = i To UBound(Grp)
StrPrt = StrPrt Grp(j)
Next j
For j = 0 To i - 1
Me.Print StrPrt
Next i
没错!!
你的算法是:
①定义三个变量,minValue(放最小值),X(放最小值的X坐标),Y(放最小值的Y坐标).
Private Sub Command1_Click()
Dim i As Integer
px(i) = Int(Rnd * 1000)
py(i) = Int(Rnd * 1000)
pz(i) = Int(Rnd * 1000)
Debug.Print px(i + 1) - px(i), 0, py(i) - py(i + 1)
Debug.Print py(i + 1) - py(i), 0, px(i + 1) - px(i)
Debug.Print pz(i + 1) - pz(i), -1, 0
Debug.Print "---------------------------------------"
以下是运行后的部分示例结果:希望对你有帮助
---------------------------------------
以上就是土嘎嘎小编为大家整理的矩阵计算vb.net相关主题介绍,如果您觉得小编更新的文章只要能对粉丝们有用,就是我们最大的鼓励和动力,不要忘记讲本站分享给您身边的朋友哦!!