-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtraitement.c
More file actions
58 lines (52 loc) · 1.35 KB
/
Copy pathtraitement.c
File metadata and controls
58 lines (52 loc) · 1.35 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
/*
** EPITECH PROJECT, 2024
** B-CPE-110-LYN-1-1-settingup-pierre.riss
** File description:
** traitement.c
*/
#include "include/my.h"
#include "include/struct.h"
#include "include/other_libs.h"
#include <stdlib.h>
#include <stdio.h>
void static fill_historigram(int x, int i, char *map, int_array_t nbrs)
{
if (map[i + x] == '.'){
nbrs.array[i]++;
}
if (map[i + x] == 'o'){
nbrs.array[i] = 0;
}
}
char *modify_map(char *map, int width, struct max_square_info *max_square)
{
int i = 0;
for (int d = 0; d < max_square->max; d++){
i = max_square->cordo + (max_square->max_y - d) * (width + 1);
for (int j = i; j < i + max_square->max; j++){
map[j] = 'x';
}
}
return map;
}
int traitement(int max_height, int width, char *map)
{
int_array_t nbrs;
struct max_square_info max_square;
max_square.cordo = 0;
max_square.max = 0;
max_square.y = -1;
max_square.max_y = 0;
nbrs.len = width;
instantiatte_array_nbr(&nbrs, width);
for (int height = 0; height < max_height; height++){
for (int i = 0; i < nbrs.len; i++){
fill_historigram((height * (width + 1)), i, map, nbrs);
}
find_max_square(nbrs, &max_square);
}
my_printf("%s", modify_map(map, width, &max_square));
free(map);
free(nbrs.array);
return 0;
}