#include <stdio.h>
#include <stdlib.h>
void pp(int *a, int r, int c,const char *msg)
{
int i,j;
for ( i = 0; i < r; ++i) {
for ( j = 0; j < c; ++j) {
}
}
}
int
main()
{
int a[][2] = {
{1, 2},
{3, 4},
{5, 6}
};
int b[][3] = {
{1, 2, 4},
{3, 6, 9}
};
int row = sizeof(a) / sizeof(a[0]);
int col = sizeof(a[0]) / sizeof(int);
int *c
= (int *)malloc(sizeof(int) * row
* col
); int i;
for (i = 0; i < row * row; ++i) {
int w1 = i / row * col, w2 = i % row;
c[i] += *(*a + w1) * *(*b + w2);
w1 += col;
w2 += row;
c[i] += *(*a + w1) * *(*b + w2);
}
pp(*a,3,2,"行列xを表示");
pp(*b,2,3,"行列yを表示");
pp(c,3,3,"行列xとyの積を表示");
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCnZvaWQgcHAoaW50ICphLCBpbnQgciwgaW50IGMsY29uc3QgY2hhciAqbXNnKQp7CiAgaW50IGksajsKICBwcmludGYoIiVzXG4iLCBtc2cpOwogIGZvciAoIGkgPSAwOyBpIDwgcjsgKytpKSB7CiAgICBmb3IgKCBqID0gMDsgaiA8IGM7ICsraikgewogICAgICBwcmludGYoIiU0ZCIsICphKyspOwogICAgfQogICAgcHV0cygiIik7CiAgfQogIHB1dHMoIiIpOwp9CgppbnQKbWFpbigpCnsKICBpbnQgICAgICAgICAgICAgYVtdWzJdID0gewogICAgezEsIDJ9LAogICAgezMsIDR9LAogICAgezUsIDZ9CiAgfTsKICBpbnQgICAgICAgICAgICAgYltdWzNdID0gewogICAgezEsIDIsIDR9LAogICAgezMsIDYsIDl9CiAgfTsKCiAgaW50IHJvdyA9IHNpemVvZihhKSAvIHNpemVvZihhWzBdKTsKICBpbnQgY29sID0gc2l6ZW9mKGFbMF0pIC8gc2l6ZW9mKGludCk7CiAgaW50ICpjID0gKGludCAqKW1hbGxvYyhzaXplb2YoaW50KSAqIHJvdyAqIGNvbCk7CiAgaW50IGk7CiAgZm9yIChpID0gMDsgaSA8IHJvdyAqIHJvdzsgKytpKSB7CiAgICBpbnQgdzEgPSBpIC8gcm93ICogY29sLCB3MiA9IGkgJSByb3c7CiAgICBjW2ldICs9ICooKmEgKyB3MSkgKiAqKCpiICsgdzIpOwogICAgdzEgKz0gY29sOwogICAgdzIgKz0gcm93OwogICAgY1tpXSArPSAqKCphICsgdzEpICogKigqYiArIHcyKTsKICB9CgogIHBwKCphLDMsMiwi6KGM5YiXeOOCkuihqOekuiIpOwogIHBwKCpiLDIsMywi6KGM5YiXeeOCkuihqOekuiIpOwogIHBwKGMsMywzLCLooYzliJd444GoeeOBruepjeOCkuihqOekuiIpOwoKICByZXR1cm4gMDsKfQ==