#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语言程序设计教程(第三版)课后习题5.8 (C语言代码)浏览:702 |
点我有惊喜!你懂得!浏览:1513 |
点我有惊喜!你懂得!浏览:2071 |
C语言程序设计教程(第三版)课后习题7.4 (C语言代码)浏览:440 |
C语言训练-阶乘和数* (C语言代码)浏览:978 |
C语言考试练习题_保留字母 (C语言代码)浏览:561 |
C语言训练-求素数问题 (C语言代码)浏览:719 |
C语言程序设计教程(第三版)课后习题9.3 (Java代码)浏览:956 |
C语言程序设计教程(第三版)课后习题4.9 (C语言代码)浏览:1514 |
WU-字符串比较 (C++代码)浏览:754 |