#include <stdio.h>
#include <stdlib.h>
int main() {
int rows = 3;
int cols = 4;
int **array;
// 行のポインタ配列を確保
array
= (int **)malloc(rows
* sizeof(int *)); // 各行のメモリを確保
for (int i = 0; i < rows; i++) {
array
[i
] = (int *)malloc(cols
* sizeof(int)); }
// 配列を使用
for (int i = 0; i < rows; i++) {
for (int j = 0; j < cols; j++) {
array[i][j] = i * cols + j;
}
}
// メモリを解放
for (int i = 0; i < rows; i++) {
}
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KaW50IG1haW4oKSB7CiAgICBpbnQgcm93cyA9IDM7CiAgICBpbnQgY29scyA9IDQ7CiAgICBpbnQgKiphcnJheTsKICAgIC8vIOihjOOBruODneOCpOODs+OCv+mFjeWIl+OCkueiuuS/nQogICAgYXJyYXkgPSAoaW50ICoqKW1hbGxvYyhyb3dzICogc2l6ZW9mKGludCAqKSk7CiAgICAvLyDlkITooYzjga7jg6Hjg6Ljg6rjgpLnorrkv50KICAgIGZvciAoaW50IGkgPSAwOyBpIDwgcm93czsgaSsrKSB7CiAgICAgICAgYXJyYXlbaV0gPSAoaW50ICopbWFsbG9jKGNvbHMgKiBzaXplb2YoaW50KSk7CiAgICB9CiAgICAvLyDphY3liJfjgpLkvb/nlKgKICAgIGZvciAoaW50IGkgPSAwOyBpIDwgcm93czsgaSsrKSB7CiAgICAgICAgZm9yIChpbnQgaiA9IDA7IGogPCBjb2xzOyBqKyspIHsKICAgICAgICAgICAgYXJyYXlbaV1bal0gPSBpICogY29scyArIGo7CiAgICAgICAgICAgIHByaW50ZigiJWQgIiwgYXJyYXlbaV1bal0pOwogICAgICAgIH0KICAgICAgICBwcmludGYoIlxuIik7CiAgICB9CiAgICAvLyDjg6Hjg6Ljg6rjgpLop6PmlL4KICAgIGZvciAoaW50IGkgPSAwOyBpIDwgcm93czsgaSsrKSB7CiAgICAgICAgZnJlZShhcnJheVtpXSk7CiAgICB9CiAgICBmcmVlKGFycmF5KTsKICAgIHJldHVybiAwOwp9