#include <stdio.h>
//2x3行列の表示
void printMatrix(int mt[][3])
{
int i,j;
for(i = 0;i < 2;i++) {
for(j = 0;j < 3;j++) {
printf("%d ", mt[i][j]);
}
printf("\n");
}
}
//2x3行列の加算
//mt1とmt2の加算結果をmtAnsに格納する
void addMatrix(int mtAns[][3], int mt1[][3], int mt2[][3])
{
int i,j;
for(i = 0;i < 2;i++) {
for(j = 0;j < 3;j++) {
mtAns[i][j] = mt1[i][j] + mt2[i][j];
}
}
}
int main(int argc, char *argv[])
{
int matrix1[][3] = {
{ 2, 3, 4 },
{ 5, 6, 7 },
};
int matrix2[2][3] = {
{ 7, 6, 5 },
{ 4, 3, 2 },
};
int matrixAns[][3] = {
{ 0, 0, 0 },
{ 0, 0, 0 },
};
printf("matrix1\n");
printMatrix(matrix1);
printf("\nmatrix2\n");
printMatrix(matrix2);
printf("\n\n");
addMatrix(matrixAns, matrix1, matrix2);
printf("Matrix add\n");
printMatrix(matrixAns);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CgovLzJ4M+ihjOWIl+OBruihqOekugp2b2lkIHByaW50TWF0cml4KGludCBtdFtdWzNdKQp7CiAgICBpbnQgICAgICAgIGksajsKCiAgICBmb3IoaSA9IDA7aSA8IDI7aSsrKSB7CiAgICAgICAgZm9yKGogPSAwO2ogPCAzO2orKykgewogICAgICAgICAgICBwcmludGYoIiVkICIsIG10W2ldW2pdKTsKICAgICAgICB9CiAgICAgICAgcHJpbnRmKCJcbiIpOwogICAgfQp9CgovLzJ4M+ihjOWIl+OBruWKoOeulwovL210MeOBqG10MuOBruWKoOeul+e1kOaenOOCkm10QW5z44Gr5qC857SN44GZ44KLCnZvaWQgYWRkTWF0cml4KGludCBtdEFuc1tdWzNdLCBpbnQgbXQxW11bM10sIGludCBtdDJbXVszXSkKewogICAgaW50IGksajsKCiAgICBmb3IoaSA9IDA7aSA8IDI7aSsrKSB7CiAgICAgICAgZm9yKGogPSAwO2ogPCAzO2orKykgewogICAgICAgICAgICBtdEFuc1tpXVtqXSA9IG10MVtpXVtqXSArIG10MltpXVtqXTsKICAgICAgICB9CiAgICB9Cn0KCmludCBtYWluKGludCBhcmdjLCBjaGFyICphcmd2W10pCnsKICAgIGludCBtYXRyaXgxW11bM10gPSB7CiAgICAgICAgeyAyLCAzLCA0IH0sCiAgICAgICAgeyA1LCA2LCA3IH0sCiAgICB9OwogICAgaW50IG1hdHJpeDJbMl1bM10gPSB7CiAgICAgICAgeyA3LCA2LCA1IH0sCiAgICAgICAgeyA0LCAzLCAyIH0sCiAgICB9OwogICAgaW50IG1hdHJpeEFuc1tdWzNdID0gewogICAgICAgIHsgMCwgMCwgMCB9LAogICAgICAgIHsgMCwgMCwgMCB9LAogICAgfTsKCiAgICBwcmludGYoIm1hdHJpeDFcbiIpOwogICAgcHJpbnRNYXRyaXgobWF0cml4MSk7CiAgICBwcmludGYoIlxubWF0cml4MlxuIik7CiAgICBwcmludE1hdHJpeChtYXRyaXgyKTsKICAgIHByaW50ZigiXG5cbiIpOwoKICAgIGFkZE1hdHJpeChtYXRyaXhBbnMsIG1hdHJpeDEsIG1hdHJpeDIpOwoKICAgIHByaW50ZigiTWF0cml4IGFkZFxuIik7CiAgICBwcmludE1hdHJpeChtYXRyaXhBbnMpOwoKICAgIHJldHVybiAgICAwOwp9Cg==