#include <stdio.h>
#define DIM 100
typedef struct {
int n, m;
int M[DIM][DIM];
} Matrix;
int multiply(Matrix A, Matrix B, Matrix *C) {
if(A.n - B.m) return 0;
for(int i = 0; i < A.n; ++i) {
for(int j = 0; j < B.m; ++j) {
C->M[ i ][ j ] = 0;
}
}
C->n = A.n;
C->m = B.m;
for(int i = 0; i < A.n; ++i) {
for(int j = 0; j < B.m; ++j) {
for(int k = 0; k < A.n; ++k) {
C->M[i][j] += A.M[i][k] * B.M[k][j];
}
}
}
printf("Matrix Multiplication:\n"); return 1;
}
void read(Matrix *mat) {
int n, m;
mat->n = n;
mat->m = m;
for(int i = 0; i < n; ++i) {
for(int j = 0; j < m; ++j) {
scanf("%d", &mat
->M
[i
][j
]); }
}
}
void display(Matrix mat) {
for(int i = 0; i < mat.n; ++i) {
for(int j = 0; j < mat.m; ++j) {
}
}
}
int main(int argc, char const *argv[]) {
Matrix A, B, C;
read(&A);
display(A);
read(&B);
display(B);
if( multiply(A,B,&C) == 1)
display(C);
else printf("No Multiplication!");
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNkZWZpbmUgRElNIDEwMAoKdHlwZWRlZiBzdHJ1Y3QgewogICAgICAgIGludCBuLCBtOwogICAgICAgIGludCBNW0RJTV1bRElNXTsKfSBNYXRyaXg7CgppbnQgbXVsdGlwbHkoTWF0cml4IEEsIE1hdHJpeCBCLCBNYXRyaXggKkMpIHsKCiAgICBpZihBLm4gLSBCLm0pIHJldHVybiAwOwoKICAgICBmb3IoaW50IGkgPSAwOyBpIDwgQS5uOyArK2kpIHsKCiAgICAgICBmb3IoaW50IGogPSAwOyBqIDwgQi5tOyArK2opIHsKCiAgICAgICAgICAgQy0+TVsgaSBdWyBqIF0gPSAwOwogICAgICAgfQogICAgIH0KCiAgICAgQy0+biA9IEEubjsKICAgICBDLT5tID0gQi5tOwoKICAgICBmb3IoaW50IGkgPSAwOyBpIDwgQS5uOyArK2kpIHsKCiAgICAgICBmb3IoaW50IGogPSAwOyBqIDwgQi5tOyArK2opIHsKCiAgICAgICAgIGZvcihpbnQgayA9IDA7IGsgPCBBLm47ICsraykgewoKICAgICAgICAgICBDLT5NW2ldW2pdICs9IEEuTVtpXVtrXSAqIEIuTVtrXVtqXTsKICAgICAgICAgfQogICAgICAgfQogICAgIH0KCiAgICAgcHJpbnRmKCJNYXRyaXggTXVsdGlwbGljYXRpb246XG4iKTsKICAgICByZXR1cm4gMTsKfQoKdm9pZCByZWFkKE1hdHJpeCAqbWF0KSB7CiAgICAgaW50IG4sIG07CiAgICAgcHJpbnRmKCJMaW5lcyA9ICIpOwogICAgIHNjYW5mKCIlZCIsICZuKTsKICAgICBtYXQtPm4gPSBuOwogICAgIHByaW50ZigiQ29scyA9ICIpOwogICAgIHNjYW5mKCIlZCIsICZtKTsKICAgICBtYXQtPm0gPSBtOwogICAgIGZvcihpbnQgaSA9IDA7IGkgPCBuOyArK2kpIHsKICAgICAgIGZvcihpbnQgaiA9IDA7IGogPCBtOyArK2opIHsKICAgICAgICAgcHJpbnRmKCJtYXRbJWRdWyVkXT0iLGksaik7CiAgICAgICAgIHNjYW5mKCIlZCIsICZtYXQtPk1baV1bal0pOwogICAgICAgfQogICAgIH0KCn0KCnZvaWQgZGlzcGxheShNYXRyaXggbWF0KSB7CgogICAgIGZvcihpbnQgaSA9IDA7IGkgPCBtYXQubjsgKytpKSB7CiAgICAgICBmb3IoaW50IGogPSAwOyBqIDwgbWF0Lm07ICsraikgewogICAgICAgICBwcmludGYoIiVkICIsbWF0Lk1baV1bal0pOwogICAgICAgfQogICAgICAgcHJpbnRmKCJcbiIpOwogICAgIH0KfQoKCmludCBtYWluKGludCBhcmdjLCBjaGFyIGNvbnN0ICphcmd2W10pIHsKCiAgTWF0cml4IEEsIEIsIEM7CiAgcmVhZCgmQSk7CiAgZGlzcGxheShBKTsKICByZWFkKCZCKTsKICBkaXNwbGF5KEIpOwoKICBpZiggbXVsdGlwbHkoQSxCLCZDKSA9PSAxKQoKICAgICAgZGlzcGxheShDKTsKCiAgZWxzZSBwcmludGYoIk5vIE11bHRpcGxpY2F0aW9uISIpOwoKICByZXR1cm4gMDsKfQ==