#include <stdio.h>
#include <stdlib.h>
int main(){
int i, j;
int a, b;
int **mat;
//---- 2次元配列の動的確保 ----
mat
= (int**)malloc(sizeof(int*)*a
); if(mat == NULL){
return 0;
}
for(i = 0; i < a; i++){
mat
[i
] = (int*)malloc(sizeof(int)*b
); if(mat[i] == NULL){
return 0;
}
}
//---- [0][0] から順に 1,2,3,... を代入 ----
int val = 1;
for(i = 0; i < a; i++){
for(j = 0; j < b; j++){
mat[i][j] = val++;
}
}
//---- 表示 ----
for(i = 0; i < a; i++){
for(j = 0; j < b; j++){
}
}
//---- メモリ解放 ----
for(i = 0; i < a; i++){
}
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCmludCBtYWluKCl7CiAgICBpbnQgaSwgajsKICAgIGludCBhLCBiOwogICAgaW50ICoqbWF0OwoKICAgIHNjYW5mKCIlZCAlZCIsICZhLCAmYik7CgogICAgLy8tLS0tIDLmrKHlhYPphY3liJfjga7li5XnmoTnorrkv50gLS0tLQogICAgbWF0ID0gKGludCoqKW1hbGxvYyhzaXplb2YoaW50KikqYSk7CiAgICBpZihtYXQgPT0gTlVMTCl7CiAgICAgICAgcHJpbnRmKCJFUlJPUlxuIik7CiAgICAgICAgcmV0dXJuIDA7CiAgICB9CgogICAgZm9yKGkgPSAwOyBpIDwgYTsgaSsrKXsKICAgICAgICBtYXRbaV0gPSAoaW50KiltYWxsb2Moc2l6ZW9mKGludCkqYik7CiAgICAgICAgaWYobWF0W2ldID09IE5VTEwpewogICAgICAgICAgICBwcmludGYoIkVSUk9SXG4iKTsKICAgICAgICAgICAgcmV0dXJuIDA7CiAgICAgICAgfQogICAgfQoKICAgIC8vLS0tLSBbMF1bMF0g44GL44KJ6aCG44GrIDEsMiwzLC4uLiDjgpLku6PlhaUgLS0tLQogICAgaW50IHZhbCA9IDE7CiAgICBmb3IoaSA9IDA7IGkgPCBhOyBpKyspewogICAgICAgIGZvcihqID0gMDsgaiA8IGI7IGorKyl7CiAgICAgICAgICAgIG1hdFtpXVtqXSA9IHZhbCsrOwogICAgICAgIH0KICAgIH0KCiAgICAvLy0tLS0g6KGo56S6IC0tLS0KICAgIGZvcihpID0gMDsgaSA8IGE7IGkrKyl7CiAgICAgICAgZm9yKGogPSAwOyBqIDwgYjsgaisrKXsKICAgICAgICAgICAgcHJpbnRmKCIlZCAiLCBtYXRbaV1bal0pOwogICAgICAgIH0KICAgICAgICBwcmludGYoIlxuIik7CiAgICB9CgogICAgLy8tLS0tIOODoeODouODquino+aUviAtLS0tCiAgICBmb3IoaSA9IDA7IGkgPCBhOyBpKyspewogICAgICAgIGZyZWUobWF0W2ldKTsKICAgIH0KICAgIGZyZWUobWF0KTsKCiAgICByZXR1cm4gMDsKfQoKCg==