文章
84
粉丝
408
获赞
33
访问
870.3k
遍历就完事了
#include<iostream>
using namespace std;
int main()
{
int a[3][3], b[3][3], c[3][3];
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
cin >> a[i][j];
}
}
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
cin >> b[i][j];
}
}
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
c[i][j] = 0;
for (int k = 0; k < 3; k++) {
c[i][j] += a[i][k] * b[k][j];
}
}
}
for (int i = 0; i < 3; i++) {
for (int j = 0; j < 2; j++) {
cout << c[i][j] << " ";
}
cout << c[i][2] << endl;
}
return 0;
}
登录后发布评论
暂无评论,来抢沙发