我们专注攀枝花网站设计 攀枝花网站制作 攀枝花网站建设
成都网站建设公司服务热线:400-028-6601

网站建设知识

十年网站开发经验 + 多家企业客户 + 靠谱的建站团队

量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决

vb.net设计矩阵相乘 矩阵相乘编程C语言

VB设计一个支持矩阵加减乘运算的程序

Const M = 5

公司主营业务:成都网站设计、网站建设、移动网站开发等业务。帮助企业客户真正实现互联网宣传,提高企业的竞争能力。创新互联公司是一支青春激扬、勤奋敬业、活力青春激扬、勤奋敬业、活力澎湃、和谐高效的团队。公司秉承以“开放、自由、严谨、自律”为核心的企业文化,感谢他们对我们的高要求,感谢他们从不同领域给我们带来的挑战,让我们激情的团队有机会用头脑与智慧不断的给客户带来惊喜。创新互联公司推出赛罕免费做网站回馈大家。

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

Print

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()

'为数组aa和bb赋初值,可根据自己需要进行赋值

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

求助!用Vb.net编写两个矩阵相乘!

Public Shared Sub Main()

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

VB.NET写了一个矩阵乘法的程序 代码如下

淳朴,古拙,淡泊,深远。闲居山林,逍遥河上,也许人只有摆脱了物欲的禁锢,才能让灵魂得到飞升。不识字烟波钓叟,傲杀人见万户侯;闲居山野的隐士,羞煞世上名利客。

斜风细雨,江南春色,落英缤纷。春水媚,绿波盈,青山横,白鹭飞。披蓑戴笠,心逐白云,意随鱼戏,行到水穷,坐看云起,卧听风韵松涛。不须归,不须归,只任心灵,放逐在深爱的自然里,忘世忘机。

《芥子园画谱》云:“与山水有顾盼,人似看山,山亦似俯而看人”。司空图《诗品冲淡》说:“遇之非深,即之逾稀。”空灵天真,非性情中人而不能为。梅妻鹤子友麋鹿,是怎样一种超逸?


本文标题:vb.net设计矩阵相乘 矩阵相乘编程C语言
网页路径:http://mswzjz.cn/article/doodjis.html

其他资讯