給你一個(gè)函數(shù) 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為第一個(gè)矢量,x2,y2,z2為第二個(gè)矢量xnew,ynew,znew為得到的新矢量
十余年的石臺(tái)網(wǎng)站建設(shè)經(jīng)驗(yàn),針對(duì)設(shè)計(jì)、前端、開(kāi)發(fā)、售后、文案、推廣等六對(duì)一服務(wù),響應(yīng)快,48小時(shí)及時(shí)工作處理。成都全網(wǎng)營(yíng)銷(xiāo)的優(yōu)勢(shì)是能夠根據(jù)用戶設(shè)備顯示端的尺寸不同,自動(dòng)調(diào)整石臺(tái)建站的顯示方式,使網(wǎng)站能夠適用不同顯示終端,在瀏覽器中調(diào)整網(wǎng)站的寬度,無(wú)論在任何一種瀏覽器上瀏覽網(wǎng)站,都能展現(xiàn)優(yōu)雅布局與設(shè)計(jì),從而大程度地提升瀏覽體驗(yàn)。創(chuàng)新互聯(lián)建站從事“石臺(tái)網(wǎng)站設(shè)計(jì)”,“石臺(tái)網(wǎng)站推廣”以來(lái),每個(gè)客戶項(xiàng)目都認(rèn)真落實(shí)執(zhí)行。
沒(méi)錯(cuò)!!
你的算法是:
1.定義三個(gè)變量,minValue(放最小值),X(放最小值的X坐標(biāo)),Y(放最小值的Y坐標(biāo))。
2.遍歷矩陣。在遍歷過(guò)程中將最小值放在minValue中,最小值的X坐標(biāo)放在X中,最小值的Y坐標(biāo)放在X中。
Public Shared Sub Main()
Dim a As Integer, b As Integer, c As Integer, d As Integer
Console.WriteLine("該程序?qū)⑶蟪鰞蓚€(gè)矩陣的積:")
Console.WriteLine("請(qǐng)指定矩陣A的行數(shù):")
a = Integer.Parse(Console.ReadLine())
Console.WriteLine("請(qǐng)指定矩陣A的列數(shù):")
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("請(qǐng)輸入矩陣A第{0}行第{1}列的值:", i + 1, j + 1)
MatrixA(i, j) = Integer.Parse(Console.ReadLine())
Next
Next
Console.WriteLine("矩陣A輸入完畢.")
Console.WriteLine("請(qǐng)指定矩陣B的行數(shù):")
c = Integer.Parse(Console.ReadLine())
Console.WriteLine("請(qǐng)指定矩陣B的列數(shù):")
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("請(qǐng)輸入矩陣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的列數(shù)與矩陣B的行數(shù)不相等,無(wú)法進(jìn)行乘積運(yùn)算!")
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