-
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathtwo.c
More file actions
25 lines (19 loc) · 603 Bytes
/
Copy pathtwo.c
File metadata and controls
25 lines (19 loc) · 603 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#include "config.h"
int main(int argc, char ** argv) {
// размер массива
if(argc != 3) { abort(); }
size_t arr_h = atoi(argv[1]);
size_t arr_w = atoi(argv[2]);
if((arr_h == 0) || (arr_w == 0)) { abort(); }
// бронируем память
double ** mem = malloc(arr_h * sizeof(double *) + arr_w * arr_h * sizeof(double));
for(size_t h = 0; h < arr_h; h++) {
mem[h] = (double *)(&mem[arr_h]) + h * arr_w;
for(size_t w = 0; w < arr_w; w++) {
mem[h][w] = h + 1.1;
}
}
// освобождаем память
free(mem);
return EXIT_SUCCESS;
}