Const M = 5
創(chuàng)新互聯(lián)主要從事成都網(wǎng)站制作、做網(wǎng)站、網(wǎng)頁設(shè)計(jì)、企業(yè)做網(wǎng)站、公司建網(wǎng)站等業(yè)務(wù)。立足成都服務(wù)井陘,10年網(wǎng)站建設(shè)經(jīng)驗(yàn),價(jià)格優(yōu)惠、服務(wù)專業(yè),歡迎來電咨詢建站服務(wù):18980820575
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ù)自己需要進(jìn)行賦值
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("該程序?qū)⑶蟪鰞蓚€(gè)矩陣的積:")
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ù)不相等,無法進(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
'建立4個(gè)label1(),index 0--3。6個(gè)label2(),index 0--5。6個(gè)text1(),index 0--5
'建立1個(gè)label3,兩個(gè)command1和2
'Form1.MaxButton = False
Dim I As Byte, J As Byte, A As Byte, B As Byte
Dim M As Byte, N As Byte, MN As Byte
Dim JZ1() As Single, JZ2() As Single, JZ3() As Single
Dim SS As String
Private Sub Command1_Click()
If Command1.Caption = "確定" Then
Command1.Caption = "完成"
ReDim JZ1(1 To M, 1 To MN) As Single
ReDim JZ2(1 To MN, 1 To N) As Single
ReDim JZ3(1 To M, 1 To N) As Single
For I = 0 To 5
Text1(I).Locked = True
Text1(I).BackColor = HF0F0F0
Text1(I).BorderStyle = 0
Next I
Label3.Caption = "請輸入相乘的兩個(gè)矩陣,輸入完成后按完成鍵"
For I = 1 To M
For J = 1 To MN
JZ1(I, J) = Val(InputBox("第一個(gè)矩陣____第" + Str(I) + "行 第" + Str(J) + "列元素:", "輸入矩陣", 3))
CurrentX = 100 + (J - 1) * 350
CurrentY = 1000 + (I - 1) * 200
Print JZ1(I, J)
Next
Next
For I = 1 To MN
For J = 1 To N
JZ2(I, J) = Val(InputBox("第二個(gè)矩陣____第" + Str(I) + "行 第" + Str(J) + "列元素:", "輸入矩陣", 3))
CurrentX = 3000 + (J - 1) * 350
CurrentY = 1000 + (I - 1) * 200
Print JZ2(I, J)
Next
Next
'Select Case M
ElseIf Command1.Caption = "完成" Then
Command1.Caption = "重新開始"
For I = 1 To M
For J = 1 To N
JZ3(I, J) = 0
For A = 1 To MN
JZ3(I, J) = JZ3(I, J) + JZ1(I, A) * JZ2(A, J)
Next
CurrentX = 6000 + (J - 1) * 350
CurrentY = 1000 + (I - 1) * 200
Print JZ3(I, J)
Next
Next
Else
Form_Load
End If
End Sub
Private Sub Command2_Click()
End
End Sub
Private Sub Form_Load()
Cls
Form1.Width = 9000
Form1.Height = 7000
For I = 0 To 2
Label1(I).Width = 1000
Label1(I).Height = 200
Label1(I).Top = 0
Label1(I).Left = 700 + I * 3000
Label1(I).Caption = "第" + Str(I + 1) + "個(gè)矩陣"
Next
For I = 0 To 5
Text1(I).Width = 400
Text1(I).Height = 200
Text1(I).Top = 300
Label2(I).Width = 200
Label2(I).Height = Text1(I).Height
Label2(I).Top = Text1(I).Top + 50
Text1(I).Text = 2
Text1(I).Alignment = 1
If I Mod 2 Then
Text1(I).Left = I * 1500 - 300
Label2(I).Caption = "列"
Else
Text1(I).Left = 300 + I * 1500
Label2(I).Caption = "行"
End If
Label2(I).Left = Text1(I).Left + 450
Next
M = 2
N = 2
MN = 2
Text1(2).Locked = True
Text1(4).Locked = True
Text1(5).Locked = True
Text1(0).Locked = False
Text1(1).Locked = False
Text1(3).Locked = False
For I = 0 To 5
Text1(I).BackColor = HFFFFFF
Text1(I).BorderStyle = 1
Next I
Command1.Caption = "確定"
Command2.Caption = "退出"
Label3.Caption = "請輸入矩陣的行和列,完成后按確定鍵"
End Sub
Private Sub Text1_Change(Index As Integer)
Text1(2).Text = Text1(1).Text
Text1(4).Text = Text1(0).Text
Text1(5).Text = Text1(3).Text
M = Val(Text1(0).Text)
MN = Val(Text1(1).Text)
N = Val(Text1(3).Text)
End Sub
已經(jīng)運(yùn)行過。
淳樸,古拙,淡泊,深遠(yuǎn)。閑居山林,逍遙河上,也許人只有擺脫了物欲的禁錮,才能讓靈魂得到飛升。不識(shí)字煙波釣叟,傲殺人見萬戶侯;閑居山野的隱士,羞煞世上名利客。
斜風(fēng)細(xì)雨,江南春色,落英繽紛。春水媚,綠波盈,青山橫,白鷺飛。披蓑戴笠,心逐白云,意隨魚戲,行到水窮,坐看云起,臥聽風(fēng)韻松濤。不須歸,不須歸,只任心靈,放逐在深愛的自然里,忘世忘機(jī)。
《芥子園畫譜》云:“與山水有顧盼,人似看山,山亦似俯而看人”。司空圖《詩品沖淡》說:“遇之非深,即之逾稀?!笨侦`天真,非性情中人而不能為。梅妻鶴子友麋鹿,是怎樣一種超逸?