已知两个3*3矩阵a,b,
a矩阵的元素为 2 1 3 b矩阵的元素为 2 1 1
3 2 2 4 3 2
1 1 3 1 2 2
1)求c矩阵(c=a+b,即 c矩阵等于a,b矩阵对应元素相加,即c(i,j)=a(i,j)+b(i,j))。
2)求c矩阵的转置阵d(即 d(j,i)=c(i,j))。
第1个回答 2015-04-17
Private Sub Command1_Click()
Dim a(3, 3), b(3, 3), c(3, 3), d(3, 3)
stri = "2,1,3,3,2,2,1,1,3"
aa = Split(stri, ",")
k = 0
For i = 1 To 3: For j = 1 To 3
a(i, j) = Val(aa(k))
k = k + 1
Next j, i
stri = "2,1,1,4,3,2,1,2,2"
aa = Split(stri, ",")
k = 0
For i = 1 To 3: For j = 1 To 3
b(i, j) = Val(aa(k))
k = k + 1
Next j, i
'相加到C
For i = 1 To 3: For j = 1 To 3
c(i, j) = a(i, j) + b(i, j)
Next j, i
'输出C
Print "C的值"
For i = 1 To 3
For j = 1 To 3
Print c(i, j);
Next j
Print
Next i
'转置阵D
For i = 1 To 3: For j = 1 To 3
d(j, i) = c(i, j)
Next j, i
'输出D
Print "D的值"
For i = 1 To 3
For j = 1 To 3
Print d(i, j);
Next j
Print
Next i
End Sub本回答被提问者采纳
Dim a(3, 3), b(3, 3), c(3, 3), d(3, 3)
stri = "2,1,3,3,2,2,1,1,3"
aa = Split(stri, ",")
k = 0
For i = 1 To 3: For j = 1 To 3
a(i, j) = Val(aa(k))
k = k + 1
Next j, i
stri = "2,1,1,4,3,2,1,2,2"
aa = Split(stri, ",")
k = 0
For i = 1 To 3: For j = 1 To 3
b(i, j) = Val(aa(k))
k = k + 1
Next j, i
'相加到C
For i = 1 To 3: For j = 1 To 3
c(i, j) = a(i, j) + b(i, j)
Next j, i
'输出C
Print "C的值"
For i = 1 To 3
For j = 1 To 3
Print c(i, j);
Next j
Next i
'转置阵D
For i = 1 To 3: For j = 1 To 3
d(j, i) = c(i, j)
Next j, i
'输出D
Print "D的值"
For i = 1 To 3
For j = 1 To 3
Print d(i, j);
Next j
Next i
End Sub本回答被提问者采纳