Const M = 5
公司主營業(yè)務:成都網(wǎng)站設計、網(wǎng)站建設、移動網(wǎng)站開發(fā)等業(yè)務。幫助企業(yè)客戶真正實現(xiàn)互聯(lián)網(wǎng)宣傳,提高企業(yè)的競爭能力。創(chuàng)新互聯(lián)公司是一支青春激揚、勤奮敬業(yè)、活力青春激揚、勤奮敬業(yè)、活力澎湃、和諧高效的團隊。公司秉承以“開放、自由、嚴謹、自律”為核心的企業(yè)文化,感謝他們對我們的高要求,感謝他們從不同領域給我們帶來的挑戰(zhàn),讓我們激情的團隊有機會用頭腦與智慧不斷的給客戶帶來驚喜。創(chuàng)新互聯(lián)公司推出賽罕免費做網(wǎng)站回饋大家。
Const N = 5
Dim aa(M, N), bb(M, N), cc(M, N)
Sub printit(a()) '打印矩陣
For i = 1 To M
For j = 1 To N
Print Tab(j * 10); a(i, j);
Next j
Next i
End Sub
Sub jzjia(a(), b(), c()) '矩陣相加 c=a+b
For i = 1 To M
For j = 1 To N
c(i, j) = a(i, j) + b(i, j)
Next j, i
End Sub
Sub jzjian(a(), b(), c()) '矩陣相減 c=a-b
For i = 1 To M
For j = 1 To N
c(i, j) = a(i, j) - b(i, j)
Next j, i
End Sub
Sub jzcheng(a(), b(), c()) '矩陣相乘 c=a*b
For i = 1 To M
For j = 1 To N
c(i, j) = a(i, j) * b(i, j)
Next j, i
End Sub
Private Sub Command1_Click()
Cls
Print "a----------------"
printit aa
Print "b----------------"
printit bb
jzjia aa, bb, cc '相加
Print "c=a+b------------"
printit cc '輸出矩陣
jzjian aa, bb, cc '相減
Print "c=a-b------------"
printit cc
jzcheng aa, bb, cc '相乘
Print "c=a*b------------"
printit cc
End Sub
Private Sub Form_Load()
'為數(shù)組aa和bb賦初值,可根據(jù)自己需要進行賦值
For i = 1 To M
For j = 1 To N
aa(i, j) = i * j
bb(i, j) = i + j
Next j
Next i
End Sub
Public Shared Sub Main()
Dim a As Integer, b As Integer, c As Integer, d As Integer
Console.WriteLine("該程序將求出兩個矩陣的積:")
Console.WriteLine("請指定矩陣A的行數(shù):")
a = Integer.Parse(Console.ReadLine())
Console.WriteLine("請指定矩陣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("請輸入矩陣A第{0}行第{1}列的值:", i + 1, j + 1)
MatrixA(i, j) = Integer.Parse(Console.ReadLine())
Next
Next
Console.WriteLine("矩陣A輸入完畢.")
Console.WriteLine("請指定矩陣B的行數(shù):")
c = Integer.Parse(Console.ReadLine())
Console.WriteLine("請指定矩陣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("請輸入矩陣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ù)不相等,無法進行乘積運算!")
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
淳樸,古拙,淡泊,深遠。閑居山林,逍遙河上,也許人只有擺脫了物欲的禁錮,才能讓靈魂得到飛升。不識字煙波釣叟,傲殺人見萬戶侯;閑居山野的隱士,羞煞世上名利客。
斜風細雨,江南春色,落英繽紛。春水媚,綠波盈,青山橫,白鷺飛。披蓑戴笠,心逐白云,意隨魚戲,行到水窮,坐看云起,臥聽風韻松濤。不須歸,不須歸,只任心靈,放逐在深愛的自然里,忘世忘機。
《芥子園畫譜》云:“與山水有顧盼,人似看山,山亦似俯而看人”。司空圖《詩品沖淡》說:“遇之非深,即之逾稀?!笨侦`天真,非性情中人而不能為。梅妻鶴子友麋鹿,是怎樣一種超逸?