#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语言考试练习题_排列 (C语言代码)浏览:1326 |
简单的a+b (C语言代码)浏览:530 |
C语言程序设计教程(第三版)课后习题1.5 (C语言代码)浏览:591 |
C语言程序设计教程(第三版)课后习题9.3 (C语言代码)浏览:679 |
2^k进制数 (C语言描述,蓝桥杯)浏览:1420 |
IP判断 (C语言代码)浏览:539 |
川哥的吩咐 (C语言代码)浏览:611 |
C语言程序设计教程(第三版)课后习题7.4 (C语言代码)浏览:450 |
C语言程序设计教程(第三版)课后习题10.5 (C语言代码)浏览:562 |
简单的a+b (C语言代码)浏览:587 |