#include <stdio.h>
#include <stdlib.h>
//必要があれば変数などを追加してもOKです
int memError(int* mat) {
if (mat==NULL) {
printf("ERROR: failed to secure memory.\n"); return 1;
}
return 0;
}
int main(){
int i,j,k;
int a,b;
int **mat;
//ここで2次元配列の動的確保をする
mat
= (int **)malloc(sizeof(int*)*a
); if(memError(mat)) return 1;
for(k=0; k<a; k++) {
mat
[k
] = (int *)malloc(sizeof(int)*b
); if(memError(mat[k])) return 1;
}
//ここで2次元配列に数値を代入する
int counter = 1;
for(i=0;i<a;i++){
for(j=0;j<b;j++){
mat[i][j] = counter++;
}
}
//以下の部分は表示の部分です
//いじらなくてOK
for(i=0;i<a;i++){
for(j=0;j<b;j++){
}
}
//さて,最後に忘れずにすることと言えば?
for (i = 0; i < a; i++) {
}
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCi8v5b+F6KaB44GM44GC44KM44Gw5aSJ5pWw44Gq44Gp44KS6L+95Yqg44GX44Gm44KCT0vjgafjgZkKaW50IG1lbUVycm9yKGludCogbWF0KSB7CglpZiAobWF0PT1OVUxMKSB7CiAgICAJcHJpbnRmKCJFUlJPUjogZmFpbGVkIHRvIHNlY3VyZSBtZW1vcnkuXG4iKTsKICAgIAlyZXR1cm4gMTsKICAgIH0KICAgIHJldHVybiAwOwp9CgppbnQgbWFpbigpewogICAgaW50IGksaixrOwogICAgaW50IGEsYjsKICAgIGludCAqKm1hdDsKICAgIHNjYW5mKCIlZCAlZCIsJmEsJmIpOwoKCS8v44GT44GT44GnMuasoeWFg+mFjeWIl+OBruWLleeahOeiuuS/neOCkuOBmeOCiwogICAgbWF0ID0gKGludCAqKiltYWxsb2Moc2l6ZW9mKGludCopKmEpOwogICAgaWYobWVtRXJyb3IobWF0KSkgcmV0dXJuIDE7CiAgICAKICAgIGZvcihrPTA7IGs8YTsgaysrKSB7CiAgICAJbWF0W2tdID0gKGludCAqKW1hbGxvYyhzaXplb2YoaW50KSpiKTsKICAgIAlpZihtZW1FcnJvcihtYXRba10pKSByZXR1cm4gMTsKICAgIH0KCiAgICAKCS8v44GT44GT44GnMuasoeWFg+mFjeWIl+OBq+aVsOWApOOCkuS7o+WFpeOBmeOCiwoJaW50IGNvdW50ZXIgPSAxOwoJZm9yKGk9MDtpPGE7aSsrKXsKICAgICAgICBmb3Ioaj0wO2o8YjtqKyspewogICAgICAgICAgICBtYXRbaV1bal0gPSBjb3VudGVyKys7CiAgICAgICAgfQogICAgfQogICAgCiAgICAvL+S7peS4i+OBrumDqOWIhuOBr+ihqOekuuOBrumDqOWIhuOBp+OBmQogICAgLy/jgYTjgZjjgonjgarjgY/jgaZPSwogICAgZm9yKGk9MDtpPGE7aSsrKXsKICAgICAgICBmb3Ioaj0wO2o8YjtqKyspewogICAgICAgICAgICBwcmludGYoIiVkICIsbWF0W2ldW2pdKTsKICAgICAgICB9CiAgICAgICAgcHJpbnRmKCJcbiIpOwogICAgfQogICAgCiAgICAvL+OBleOBpu+8jOacgOW+jOOBq+W/mOOCjOOBmuOBq+OBmeOCi+OBk+OBqOOBqOiogOOBiOOBsO+8nwogICAgZm9yIChpID0gMDsgaSA8IGE7IGkrKykgewogICAgICAgIGZyZWUobWF0W2ldKTsKICAgIH0KICAgIGZyZWUobWF0KTsKCiAgICByZXR1cm4gMDsKfQ==