VB编程:利用数组实现矩阵转换-28_彭世瑜_新浪博客
原创
©著作权归作者所有:来自51CTO博客作者彭世瑜的原创作品,请联系作者获取转载授权,否则将追究法律责任
运行效果:
运行代码:
Dim myarray(1 To 5, 1 To 5) As Long
Private Sub Command1_Click()
Print " 转换前的矩阵"
For intx = 1 To 5
For inty = 1 To 5
myarray(intx, inty) = intx * 10 + inty
Next
Next
For intx = 1 To 5
For inty = 1 To 5
Print myarray(intx, inty),
Next inty
Print
Next intx
Print vbCrLf
End Sub
Private Sub Command2_Click()
Print " 转换后的矩阵"
For intx = 1 To 5
For inty = intx To 5 '每次交换只能从intx开始,不然重复交换,就和原来的一样了。
temp = myarray(intx, inty)
myarray(intx, inty) = myarray(inty, intx)
myarray(inty, intx) = temp
Next inty
Next intx
For intx = 1 To 5
For inty = 1 To 5
Print myarray(intx, inty),
Next inty
Print
Next intx
End Sub
学习总结:
1、每次交换只能从行坐标intx开始,不然重复交换,就和原来的一样了。
提问和评论都可以,用心的回复会被更多人看到
评论
发布评论
相关文章
-
python编程-28:Scrapy爬虫框架_彭世瑜_新浪博客python Python编程教学
-
VB编程:利用Object变量传递参数-21_彭世瑜_新浪博客
运行效果:程序代码:Private Sub Command1_Click() Dim i As Object Set i = Text1 i.Text = "传递参数"End Sub
python js javascript linux java