#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
* row
); int i;
for (i = 0; i < row * row; ++i) {
int w1 = i / row * col, w2 = i % row;
c[i] = *(*a + w1) * *(*b + w2);
w1 += 1;
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+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCnZvaWQKcHAoaW50ICphLCBpbnQgciwgaW50IGMsIGNvbnN0IGNoYXIgKm1zZykKewogIGludCAgICAgICAgICAgICBpLCBqOwogIHByaW50ZigiJXNcbiIsIG1zZyk7CiAgZm9yIChpID0gMDsgaSA8IHI7ICsraSkgewogICAgZm9yIChqID0gMDsgaiA8IGM7ICsraikgewogICAgICBwcmludGYoIiU0ZCIsICphKyspOwogICAgfQogICAgcHV0cygiIik7CiAgfQogIHB1dHMoIiIpOwp9CgppbnQKbWFpbigpCnsKICBpbnQgICAgICAgICAgICAgYVtdWzJdID0gewogICAgezEsIDJ9LAogICAgezMsIDR9LAogICAgezUsIDZ9CiAgfTsKICBpbnQgICAgICAgICAgICAgYltdWzNdID0gewogICAgezEsIDIsIDR9LAogICAgezMsIDYsIDl9CiAgfTsKCiAgaW50ICAgICAgICAgICAgIHJvdyA9IHNpemVvZihhKSAvIHNpemVvZihhWzBdKTsKICBpbnQgICAgICAgICAgICAgY29sID0gc2l6ZW9mKGFbMF0pIC8gc2l6ZW9mKGludCk7CiAgaW50ICAgICAgICAgICAgKmMgPSAoaW50ICopIG1hbGxvYyhzaXplb2YoaW50KSAqIHJvdyAqIHJvdyk7CiAgaW50ICAgICAgICAgICAgIGk7CgogIGZvciAoaSA9IDA7IGkgPCByb3cgKiByb3c7ICsraSkgewogICAgaW50ICAgICAgICAgICAgIHcxID0gaSAvIHJvdyAqIGNvbCwgdzIgPSBpICUgcm93OwogICAgY1tpXSA9ICooKmEgKyB3MSkgKiAqKCpiICsgdzIpOwogICAgdzEgKz0gMTsKICAgIHcyICs9IHJvdzsKICAgIGNbaV0gKz0gKigqYSArIHcxKSAqICooKmIgKyB3Mik7CiAgfQoKICBwcCgqYSwgMywgMiwgIuihjOWIl3jjgpLooajnpLoiKTsKICBwcCgqYiwgMiwgMywgIuihjOWIl3njgpLooajnpLoiKTsKICBwcChjLCAzLCAzLCAi6KGM5YiXeOOBqHnjga7nqY3jgpLooajnpLoiKTsKCiAgcmV0dXJuIDA7Cn0=