Public Shared Sub Main()
創(chuàng)新互聯(lián)建站專(zhuān)注于云龍企業(yè)網(wǎng)站建設(shè),響應(yīng)式網(wǎng)站建設(shè),成都商城網(wǎng)站開(kāi)發(fā)。云龍網(wǎng)站建設(shè)公司,為云龍等地區(qū)提供建站服務(wù)。全流程按需求定制制作,專(zhuān)業(yè)設(shè)計(jì),全程項(xiàng)目跟蹤,創(chuàng)新互聯(lián)建站專(zhuān)業(yè)和態(tài)度為您提供的服務(wù)
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
'這是在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
要實(shí)現(xiàn)什么樣的功能呢?矩陣就是二維表吧,在.Net中有許多方法可以實(shí)現(xiàn)二維表,根據(jù)不同的需求選擇適合的方法,你應(yīng)該詳細(xì)一點(diǎn)說(shuō)明
給你一個(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為得到的新矢量
在程序設(shè)計(jì)語(yǔ)言里,用二維數(shù)組來(lái)保存矩陣的值。
一維列矩陣,就是由:若干行、一列組成的二維數(shù)組。
一維行矩陣,就是由:一行、若干列組成的二維數(shù)組。
比如一維列矩陣,的輸入:
dim a(10,1) as integer '10行,1列
dim i as integer
for i = 1 to 10
a(i,1) = inputbox("")
next i
沒(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中。