这道VB题的代码怎么写呢

 我来答
liuekj
2010-07-10 · TA获得超过162个赞
知道小有建树答主
回答量:235
采纳率:0%
帮助的人:0
展开全部
Private Sub Form_Click()

Dim A(1 To 4, 1 To 4) As Integer
Dim s As String

' 如果需要以“输入”数据的形式,可以用 InputBox 输入
's = InputBox("输入第一行数据(用空格分格): "): GetIn A, 1, s
's = InputBox("输入第二行数据(用空格分格): "): GetIn A, 2, s
's = InputBox("输入第三行数据(用空格分格): "): GetIn A, 3, s
's = InputBox("输入第四行数据(用空格分格): "): GetIn A, 4, s

s = "25 36 78 13": GetIn A, 1, s
s = "12 26 88 93": GetIn A, 2, s
s = "75 18 22 32": GetIn A, 3, s
s = "56 44 36 58": GetIn A, 4, s

Dim i As Integer
Dim j As Integer

'1 输出数组对角线上的数:
Cls
Print "第一条对条线"
For i = 1 To 4
Print A(i, i);
Next
Print
Print "第二条对条线"
For i = 1 To 4
Print A(i, 5 - i);
Next
Print

'2 交换第一和第三行
For i = 1 To 4
t = A(1, i)
A(1, i) = A(3, i)
A(3, i) = t
Next

'3 交换第二列和第四列
For i = 1 To 4
t = A(i, 2)
A(i, 2) = A(i, 4)
A(i, 4) = t
Next

'4 输出处理后数组
Print "4 输出处理后数组"
For i = 1 To 4
For j = 1 To 4
Print A(i, j);
Next
Print
Next

End Sub

Private Sub Do1(A() As Integer)
Dim i As Integer
Cls
Print "第一条对条线"
For i = 1 To 4
Print A(i, i);
Next
Print
Print "第二条对条线"
For i = 1 To 4
Print A(i, 4 - i);
Next
Print
End Sub

Private Sub GetIn(A() As Integer, iRow As Integer, s As String)
On Error Resume Next
Dim i As Integer
Dim arr
arr = Split(s, " ")
For i = 0 To 3
A(iRow, i + 1) = arr(i)
Next
End Sub
zhh0000zhh
2010-07-10 · TA获得超过386个赞
知道小有建树答主
回答量:419
采纳率:100%
帮助的人:299万
展开全部
dim a(3,3)
dim t
a(0,0)=25
a(0,1)=36
.
.
.
a(4,4)=58
for i=0 to 3
t=a(0,i)
a(0,i)=a(3,i)
a(3,i)=t
next
for i=0 to 3
t=a(1,i)
a(1,i)=a(4,i)
a(4,i)=t
next
t=""
for i=0 to 3
for j=0 to 3
t=t & " " & a(i,j)
next
t=t & vbnewline
next
me.show
print t
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式