#include <stdio.h>
#include <stdlib.h>
int main() {
int a, b;
int **matrix
= malloc(sizeof(int *) * a
); if (matrix == NULL) {
return 1;
}
for (int i = 0; i < a; i++) {
int *row
= malloc(sizeof(int) * b
); if (row == NULL) {
return 1;
}
matrix[i] = row;
}
int counter = 0;
for(int i = 0; i < a; i++) {
for(int j = 0; j < b; j++) {
matrix[i][j] = ++counter;
}
}
for(int i = 0; i < a; i++) {
for(int j = 0; j < b; j++) {
}
}
for (int i
= 0; i
< a
; i
++) free(matrix
[i
]);
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KCmludCBtYWluKCkgewogICAgaW50IGEsIGI7CiAgICBzY2FuZigiJWQgJWQiLCAmYSwgJmIpOwoKCWludCAqKm1hdHJpeCA9IG1hbGxvYyhzaXplb2YoaW50ICopICogYSk7CglpZiAobWF0cml4ID09IE5VTEwpIHsKCQlwcmludGYoImFsbG9jYXRpb24gZmFpbGVkIik7CgkJcmV0dXJuIDE7Cgl9Cglmb3IgKGludCBpID0gMDsgaSA8IGE7IGkrKykgewoJCWludCAqcm93ID0gbWFsbG9jKHNpemVvZihpbnQpICogYik7CgkJaWYgKHJvdyA9PSBOVUxMKSB7CgkJCXByaW50ZigiYWxsb2NhdGlvbiBmYWlsZWQiKTsKCQkJcmV0dXJuIDE7CgkJfQoJCW1hdHJpeFtpXSA9IHJvdzsKCX0KCglpbnQgY291bnRlciA9IDA7CiAgICBmb3IoaW50IGkgPSAwOyBpIDwgYTsgaSsrKSB7CiAgICAgICAgZm9yKGludCBqID0gMDsgaiA8IGI7IGorKykgewoJCQltYXRyaXhbaV1bal0gPSArK2NvdW50ZXI7CiAgICAgICAgfQogICAgfQoKICAgIGZvcihpbnQgaSA9IDA7IGkgPCBhOyBpKyspIHsKICAgICAgICBmb3IoaW50IGogPSAwOyBqIDwgYjsgaisrKSB7CiAgICAgICAgICAgIHByaW50ZigiJWQgIiwgbWF0cml4W2ldW2pdKTsKICAgICAgICB9CiAgICAgICAgcHJpbnRmKCJcbiIpOwogICAgfQoKCWZvciAoaW50IGkgPSAwOyBpIDwgYTsgaSsrKSBmcmVlKG1hdHJpeFtpXSk7CglmcmVlKG1hdHJpeCk7CgogICAgcmV0dXJuIDA7Cn0K