#include <stdio.h>
#include <stdlib.h>
// 必要があれば変数などを追加してもOKです
int main() {
int i, j, k;
int a, b;
int **mat; // 二次元配列へのポインタ
// 行数aと列数bの入力
// 2次元配列の動的確保
mat
= (int**)malloc(sizeof(int*) * a
); // 行ポインタの配列を確保
for (i = 0; i < a; i++) {
mat
[i
] = (int*)malloc(sizeof(int) * b
); // 各行の列を確保 }
// 2次元配列に1から順番に数値を代入する
int current = 1; // 1から始める
for (i = 0; i < a; i++) {
for (j = 0; j < b; j++) {
mat[i][j] = current++;
}
}
// 表示の部分
for (i = 0; i < a; i++) {
for (j = 0; j < b; j++) {
}
}
// 動的に確保したメモリの解放
for (i = 0; i < a; i++) {
free(mat
[i
]); // 各行のメモリを解放 }
free(mat
); // 行ポインタの配列を解放
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCi8vIOW/heimgeOBjOOBguOCjOOBsOWkieaVsOOBquOBqeOCkui/veWKoOOBl+OBpuOCgk9L44Gn44GZCgppbnQgbWFpbigpIHsKICAgIGludCBpLCBqLCBrOwogICAgaW50IGEsIGI7CiAgICBpbnQgKiptYXQ7ICAvLyDkuozmrKHlhYPphY3liJfjgbjjga7jg53jgqTjg7Pjgr8KCiAgICAvLyDooYzmlbBh44Go5YiX5pWwYuOBruWFpeWKmwogICAgc2NhbmYoIiVkICVkIiwgJmEsICZiKTsKCiAgICAvLyAy5qyh5YWD6YWN5YiX44Gu5YuV55qE56K65L+dCiAgICBtYXQgPSAoaW50KiopbWFsbG9jKHNpemVvZihpbnQqKSAqIGEpOyAgLy8g6KGM44Od44Kk44Oz44K/44Gu6YWN5YiX44KS56K65L+dCiAgICAKICAgIGZvciAoaSA9IDA7IGkgPCBhOyBpKyspIHsKICAgICAgICBtYXRbaV0gPSAoaW50KiltYWxsb2Moc2l6ZW9mKGludCkgKiBiKTsgIC8vIOWQhOihjOOBruWIl+OCkueiuuS/nQogICAgfQoKICAgIC8vIDLmrKHlhYPphY3liJfjgasx44GL44KJ6aCG55Wq44Gr5pWw5YCk44KS5Luj5YWl44GZ44KLCiAgICBpbnQgY3VycmVudCA9IDE7ICAvLyAx44GL44KJ5aeL44KB44KLCiAgICBmb3IgKGkgPSAwOyBpIDwgYTsgaSsrKSB7CiAgICAgICAgZm9yIChqID0gMDsgaiA8IGI7IGorKykgewogICAgICAgICAgICBtYXRbaV1bal0gPSBjdXJyZW50Kys7CiAgICAgICAgfQogICAgfQoKICAgIC8vIOihqOekuuOBrumDqOWIhgogICAgZm9yIChpID0gMDsgaSA8IGE7IGkrKykgewogICAgICAgIGZvciAoaiA9IDA7IGogPCBiOyBqKyspIHsKICAgICAgICAgICAgcHJpbnRmKCIlZCAiLCBtYXRbaV1bal0pOwogICAgICAgIH0KICAgICAgICBwcmludGYoIlxuIik7CiAgICB9CgogICAgLy8g5YuV55qE44Gr56K65L+d44GX44Gf44Oh44Oi44Oq44Gu6Kej5pS+CiAgICBmb3IgKGkgPSAwOyBpIDwgYTsgaSsrKSB7CiAgICAgICAgZnJlZShtYXRbaV0pOyAgLy8g5ZCE6KGM44Gu44Oh44Oi44Oq44KS6Kej5pS+CiAgICB9CiAgICBmcmVlKG1hdCk7ICAvLyDooYzjg53jgqTjg7Pjgr/jga7phY3liJfjgpLop6PmlL4KCiAgICByZXR1cm4gMDsKfQo=