#include <stdio.h>
#include <stdlib.h>
int main() {
int a, b;
// 入力を受け取る
printf("行数と列数を入力してください (例: 2 3): ");
// 動的な2次元配列を確保
int **matrix
= (int **)malloc(a
* sizeof(int *)); for (int i = 0; i < a; i++) {
matrix
[i
] = (int *)malloc(b
* sizeof(int)); }
// 配列に値を代入
int value = 1;
for (int i = 0; i < a; i++) {
for (int j = 0; j < b; j++) {
matrix[i][j] = value++;
}
}
// 配列を指定のフォーマットで出力
for (int i = 0; i < a; i++) {
for (int j = 0; j < b; j++) {
}
}
// メモリを解放
for (int i = 0; i < a; i++) {
}
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCmludCBtYWluKCkgewogICAgaW50IGEsIGI7CiAgICAKICAgIC8vIOWFpeWKm+OCkuWPl+OBkeWPluOCiwogICAgcHJpbnRmKCLooYzmlbDjgajliJfmlbDjgpLlhaXlipvjgZfjgabjgY/jgaDjgZXjgYQgKOS+izogMiAzKTogIik7CiAgICBzY2FuZigiJWQgJWQiLCAmYSwgJmIpOwoKICAgIC8vIOWLleeahOOBqjLmrKHlhYPphY3liJfjgpLnorrkv50KICAgIGludCAqKm1hdHJpeCA9IChpbnQgKiopbWFsbG9jKGEgKiBzaXplb2YoaW50ICopKTsKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgYTsgaSsrKSB7CiAgICAgICAgbWF0cml4W2ldID0gKGludCAqKW1hbGxvYyhiICogc2l6ZW9mKGludCkpOwogICAgfQoKICAgIC8vIOmFjeWIl+OBq+WApOOCkuS7o+WFpQogICAgaW50IHZhbHVlID0gMTsKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgYTsgaSsrKSB7CiAgICAgICAgZm9yIChpbnQgaiA9IDA7IGogPCBiOyBqKyspIHsKICAgICAgICAgICAgbWF0cml4W2ldW2pdID0gdmFsdWUrKzsKICAgICAgICB9CiAgICB9CgogICAgLy8g6YWN5YiX44KS5oyH5a6a44Gu44OV44Kp44O844Oe44OD44OI44Gn5Ye65YqbCiAgICBmb3IgKGludCBpID0gMDsgaSA8IGE7IGkrKykgewogICAgICAgIGZvciAoaW50IGogPSAwOyBqIDwgYjsgaisrKSB7CiAgICAgICAgICAgIHByaW50ZigiJWQgIiwgbWF0cml4W2ldW2pdKTsKICAgICAgICB9CiAgICAgICAgcHJpbnRmKCJcbiIpOwogICAgfQoKICAgIC8vIOODoeODouODquOCkuino+aUvgogICAgZm9yIChpbnQgaSA9IDA7IGkgPCBhOyBpKyspIHsKICAgICAgICBmcmVlKG1hdHJpeFtpXSk7CiAgICB9CiAgICBmcmVlKG1hdHJpeCk7CgogICAgcmV0dXJuIDA7Cn0K