#include <stdio.h>
#include <stdlib.h>
//必要があれば変数などを追加してもOKです
int main(){
int i,j,k;
int a,b;
int **mat;
//ここで2次元配列の動的確保をする
mat
= (int**)malloc(a
* sizeof(int*)); for (int i = 0; i < a; i++) {
mat
[i
] = (int*)malloc(b
* sizeof(int));}
//ここで2次元配列に数値を代入する
k=1;
for(i=0;i<a;i++){
for(j=0;j<b;j++){
mat[i][j]=k++;
}
}
//以下の部分は表示の部分です
//いじらなくてOK
for(i=0;i<a;i++){
for(j=0;j<b;j++){
}
}
//さて,最後に忘れずにすることと言えば?
for (int i = 0; i < a; i++) {
free(mat
[i
]); // 各行のメモリを解放 }
free(mat
); // 行ポインタのメモリを解放
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCi8v5b+F6KaB44GM44GC44KM44Gw5aSJ5pWw44Gq44Gp44KS6L+95Yqg44GX44Gm44KCT0vjgafjgZkKCmludCBtYWluKCl7CiAgICBpbnQgaSxqLGs7CiAgICBpbnQgYSxiOwogICAgaW50ICoqbWF0OwogICAgc2NhbmYoIiVkICVkIiwmYSwmYik7CgoJLy/jgZPjgZPjgacy5qyh5YWD6YWN5YiX44Gu5YuV55qE56K65L+d44KS44GZ44KLCgkgbWF0ID0gKGludCoqKW1hbGxvYyhhKiBzaXplb2YoaW50KikpOwoJZm9yIChpbnQgaSA9IDA7IGkgPCBhOyBpKyspIHsKICAgIG1hdFtpXSA9IChpbnQqKW1hbGxvYyhiICogc2l6ZW9mKGludCkpOwp9CgogICAgCiAgICAKCS8v44GT44GT44GnMuasoeWFg+mFjeWIl+OBq+aVsOWApOOCkuS7o+WFpeOBmeOCiwoJaz0xOwoJZm9yKGk9MDtpPGE7aSsrKXsKICAgICAgICBmb3Ioaj0wO2o8YjtqKyspewogICAgICAgIAltYXRbaV1bal09aysrOwogICAgICAgIH0KCX0KICAgIC8v5Lul5LiL44Gu6YOo5YiG44Gv6KGo56S644Gu6YOo5YiG44Gn44GZCiAgICAvL+OBhOOBmOOCieOBquOBj+OBpk9LCiAgICBmb3IoaT0wO2k8YTtpKyspewogICAgICAgIGZvcihqPTA7ajxiO2orKyl7CiAgICAgICAgICAgIHByaW50ZigiJWQgIixtYXRbaV1bal0pOwogICAgICAgIH0KICAgICAgICBwcmludGYoIlxuIik7CiAgICB9CiAgICAKICAgIC8v44GV44Gm77yM5pyA5b6M44Gr5b+Y44KM44Ga44Gr44GZ44KL44GT44Go44Go6KiA44GI44Gw77yfCmZvciAoaW50IGkgPSAwOyBpIDwgYTsgaSsrKSB7CiAgICBmcmVlKG1hdFtpXSk7IC8vIOWQhOihjOOBruODoeODouODquOCkuino+aUvgp9CmZyZWUobWF0KTsgLy8g6KGM44Od44Kk44Oz44K/44Gu44Oh44Oi44Oq44KS6Kej5pS+CgoKICAgIHJldHVybiAwOwp9Cg==