哪位高手做下这道VB题???

来源:百度知道 编辑:UC知道 时间:2024/06/23 01:10:38
编写程序,把下面的数据输入一个二维数组中:
25 36 78 13
12 26 88 93
75 18 22 32
56 44 36 58
然后执行以下操作:
(1)输出矩阵两个对角线上的数;
(2)分别输出各行和各列的和;
(3)交换第一行和第三行的位置;
(4)交换第二行和第四行的位置;
(5)输出处理后的数组。

Dim a(1 to 4,1 to 4) as integer
a(1,1)=25
a(1,2)=36
……中间省略的自己输,一直到
a(4,4)=58
'下面输出两个对角线上的数
dim i as integer,j as integer
for i = 1 to 4
for j = 1 to 4
if i=j then print a(i,j);
next j
next i
'\对角线
print
for i = 1 to 4
for j = 1 to 4
if i+j=5 then print a(i,j);
next j
next i
'/对角线
'下面输出各行的和
dim s as integer
for i = 1 to 4
s=0
for j = 1 to 4
s=s+a(i,j)
next j
print s
next i
'下面输出各列和
for j = 1 to 4
s=0
for i = 1 to 4
s=s+a(i,j)
next i
print s
next j
'下面交换1,3行
dim b as Integer
for j = 1 to 4
b=a(1,j)
a(1,j)=a(3,j)
a(3,j)=b
next j
'下面交换2,4行
for j = 1 to 4
b=a(2,j)
a(2,j)=a(4,j)
a(4,j)=b
next j
'输出数组
for i = 1 to 4
for j = 1 to 4
print a(i,j);" ";
next j
print
nex