#include <stdio.h> #include <stdlib.h>
int **create2d(int row, int col) { int i; int **pp = (int **)malloc(row * sizeof(int *)); *pp = (int *)malloc(row * col * sizeof(int)); for (i = 1; i < row; i++) pp[i] = pp[i - 1] + col; return pp; }
void free2d(int **pp) { free(*pp); free(pp); }
int main() { int m, s, n; int **a, **b; int i, j, v, p; scanf("%d%d%d", &m, &s, &n); a = create2d(m, s); b = create2d(s, n); for (i = 0; i < m; i++) for (j = 0; j < s; j++) scanf("%d", &a[i][j]); for (i = 0; i < s; i++) for (j = 0; j < n; j++) scanf("%d", &b[i][j]); for (i = 0; i < m; i++) { for (j = 0; j < n; j++) { v = 0; for (p = 0; p < s; p++) v += a[i][p] * b[p][j]; printf("%d ", v); } putchar('\n'); } free2d(a); free2d(b); return 0; }
|