-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
44 lines (35 loc) · 1009 Bytes
/
main.c
File metadata and controls
44 lines (35 loc) · 1009 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
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#include <stdio.h>
#include <stdlib.h>
#include "life.c"
int main(void) {
int n;
int t;
int d;
int **map;
printf("Введите размер поля: ");
scanf("%d", &n);
printf("Введите колличество живых клеток: ");
scanf("%d", &t);
printf("Введите колличество ходов: ");
scanf("%d", &d);
FILE *input_file;
map = (int**)malloc(sizeof(int*)*n);
for (int i = 0; i < n; i++) {
map[i] = (int*)malloc(sizeof(int)*n);
}
init_map(n, map, t);
input_file = fopen("input.txt", "w");
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
fprintf(input_file, "%d ", map[i][j]);
}
fprintf(input_file, "\n");
}
fclose(input_file);
start_life(n, map, d);
for (int i = 0; i < n; i++) {
free(map[i]);
}
free(map);
return 0;
}