#include <stdio.h> #include <iostream> #include <algorithm> using namespace std; const int maxn = 100; struct mat{ int m[maxn][maxn]; int row; int col; }; mat operator * (mat a, mat b){ mat ret; ret.row = a.row; ret.col = b.col; int n = a.col; for(int i = 0; i < a.row; i++){ for(int j = 0; j < b.col; j++){ int x = 0; for(int k = 0; k < n; k++){ x += a.m[i][k] * b.m[k][j]; } ret.m[i][j] = x; } } return ret; } int main(void){ mat a,b,c; a.row = 2; a.col = 3; b.row = 3; b.col = 2; while(cin >> a.m[0][0] >> a.m[0][1] >> a.m[0][2]){ for(int i = 1; i < a.row; i++){ for(int j = 0; j < a.col; j++){ cin >> a.m[i][j]; } } for(int i = 0; i < b.row; i++){ for(int j = 0; j < b.col; j++){ cin >> b.m[i][j]; } } c = a * b; for(int i = 0; i < c.row; i++){ for(int j = 0; j < c.col; j++){ cout << c.m[i][j] << " "; } cout << endl; } } return 0; }
0.0分
0 人评分
十->二进制转换 (C++代码)(零和负数需要特殊处理)浏览:1040 |
点我有惊喜!你懂得!浏览:3878 |
C语言程序设计教程(第三版)课后习题6.1 (C语言代码)浏览:625 |
字符串输入输出函数 (Java代码)浏览:1437 |
P1001 (C语言代码)浏览:800 |
A+B for Input-Output Practice (III) (C语言代码)浏览:570 |
WU-格式化数据输出 (C++代码)浏览:1194 |
WU-链表数据求和操作 (C++代码)浏览:1313 |
C语言程序设计教程(第三版)课后习题8.5 (C语言代码)浏览:567 |
C语言程序设计教程(第三版)课后习题8.9 (C语言代码)浏览:818 |