Public Shared Sub Main()
10年積累的網站制作、成都做網站經驗,可以快速應對客戶對網站的新想法和需求。提供各種問題對應的解決方案。讓選擇我們的客戶得到更好、更有力的網絡服務。我雖然不認識你,你也不認識我。但先網站設計后付款的網站建設流程,更有大冶免費網站建設讓你可以放心的選擇與我們合作。
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
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
Console.WriteLine("請輸入矩陣A第{0}行第{1}列的值:", i + 1, j + 1)
MatrixB(i, j) = Integer.Parse(Console.ReadLine())
Next
Next
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) {}
For i As Integer = 0 To a - 1
For j As Integer = 0 To d - 1
MatrixC(i, j) = 0
For k As Integer = 0 To b - 1
MatrixC(i, j) += MatrixA(i, k) * MatrixB(k, j)
Next
Next
Next
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)
Next
Console.WriteLine()
Next
End Sub
End Class
'這是在vb6中的代碼,在vb.net中基本差不多,你可以參考一下
Private Sub cmdCommand1_Click()
Me.AutoRedraw = True
Dim Grp
Grp = Array(1, 2, 3, 4, 5)
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
StrPrt = StrPrt Grp(j)
Next j
Me.Print StrPrt
Next i
End Sub
沒錯!!
你的算法是:
1.定義三個變量,minValue(放最小值),X(放最小值的X坐標),Y(放最小值的Y坐標)。
2.遍歷矩陣。在遍歷過程中將最小值放在minValue中,最小值的X坐標放在X中,最小值的Y坐標放在X中。
給你一個函數 Public Sub Vect1XtoVect2(ByVal x1 As Double, ByVal y1 As Double, ByVal z1 As Double, _ ByVal x2 As Double, ByVal y2 As Double, ByVal z2 As Double, _ ByRef xNew As Double, ByRef yNew As Double, ByRef zNew As Double) '矢量叉積 xNew = y1 * z2 - z1 * y2 yNew = z1 * x2 - x1 * z2 zNew = x1 * y2 - y1 * x2 End Sub其中x1,y1,z1為第一個矢量,x2,y2,z2為第二個矢量xnew,ynew,znew為得到的新矢量
網頁標題:vb.net矩陣求解,vb計算矩陣
文章位置:http://vcdvsql.cn/article48/hshghp.html
成都網站建設公司_創新互聯,為您提供外貿建站、Google、服務器托管、微信小程序、用戶體驗、建站公司
聲明:本網站發布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創新互聯