#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void removefibas(int* arr, int* size, int index) {
if (index >= 0 && index < *size) {
for (int i = index; i < *size - 1; ++i) {
arr[i] = arr[i + 1];
}
(*size)--;
}
}
int main() {
int n = 0, m = 0;
printf("enter long and width of the matrix: \n"); int** mat
= malloc(sizeof(int*) * m
); for (int i = 0; i < n; i++) {
mat
[i
] = malloc(sizeof(int) * n
); }
// Динамическое выделение памяти для массива fiba
int* fiba
= malloc(sizeof(int) * 100); // Выделяем достаточно памяти fiba[0] = 0;
fiba[1] = 1;
int fiba_count = 2;
while (fiba[fiba_count - 1] < 320000) {
fiba[fiba_count] = fiba[fiba_count - 1] + fiba[fiba_count - 2];
fiba_count++;
}
int ran = 0;
fiba_count -= 1;
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
ran
= rand() % (fiba_count
); mat[i][j] = fiba[ran];
removefibas(fiba, &fiba_count, ran);
fiba_count--;
}
if (fiba_count < 0) {
printf("its too much numbers in matrix\n"); return 0;
}
}
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++) {
}
}
// Освобождаем память
free(fiba
); // Освобождаем память для fiba for (int i = 0; i < n; i++) {
}
return 0;
}
I2luY2x1ZGUgPHN0ZGlvLmg+CiNpbmNsdWRlIDxzdGRsaWIuaD4KI2luY2x1ZGUgPHRpbWUuaD4KCnZvaWQgcmVtb3ZlZmliYXMoaW50KiBhcnIsIGludCogc2l6ZSwgaW50IGluZGV4KSB7CiAgaWYgKGluZGV4ID49IDAgJiYgaW5kZXggPCAqc2l6ZSkgewogICAgZm9yIChpbnQgaSA9IGluZGV4OyBpIDwgKnNpemUgLSAxOyArK2kpIHsKICAgICAgYXJyW2ldID0gYXJyW2kgKyAxXTsKICAgIH0KICAgICgqc2l6ZSktLTsKICB9Cn0KCmludCBtYWluKCkgewogIGludCBuID0gMCwgbSA9IDA7CiAgcHJpbnRmKCJlbnRlciBsb25nIGFuZCB3aWR0aCBvZiB0aGUgbWF0cml4OiBcb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yaXhcbiIpOwogICAgICByZXR1cm4gMDsKICAgIH0KICB9CgogIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgaSsrKSB7CiAgICBmb3IgKGludCBqID0gMDsgaiA8IG07IGorKykgewogICAgICBwcmludGYoIiVkICIsIG1hdFtpXVtqXSk7CiAgICB9CiAgICBwcmludGYoIlxuIik7CiAgfQoKICAvLyDQntGB0LLQvtCx0L7QttC00LDQtdC8INC/0LDQvNGP0YLRjAogIGZyZWUoZmliYSk7IC8vINCe0YHQstC+0LHQvtC20LTQsNC10Lwg0L/QsNC80Y/RgtGMINC00LvRjyBmaWJhCiAgZm9yIChpbnQgaSA9IDA7IGkgPCBuOyBpKyspIHsKICAgIGZyZWUobWF0W2ldKTsKICB9CiAgZnJlZShtYXQpOwoKICByZXR1cm4gMDsKfQoK