1
0
This repository has been archived on 2024-10-25. You can view files and clone it, but cannot push or open issues or pull requests.

81 lines
1.6 KiB
C
Raw Normal View History

2023-08-03 23:16:27 +02:00
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* utils.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: axdubois <axdubois@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/31 23:27:23 by axdubois #+# #+# */
/* Updated: 2023/08/02 19:28:42 by axdubois ### ########.fr */
/* */
/* ************************************************************************** */
#include "../../includes/Display-h/write.h"
#include "../../includes/utils-h/utils.h"
int ft_strlen(char *str)
{
int i;
i = 0;
while (*str != 0)
{
i++;
str++;
}
return (i);
}
void ft_swap(int *a, int *b)
{
int tmp;
tmp = *b;
*b = *a;
*a = tmp;
}
t_coords *ft_sort_x(t_coords *coords, int size)
{
t_coords *arr;
int i;
i = 0;
arr = coords;
while (i != size - 1)
{
if (arr[i].x > arr[i + 1].x)
{
ft_swap(&arr[i].x, &arr[i + 1].x);
i = 0;
}
else
{
i++;
}
}
return (arr);
}
t_coords *ft_sort_y(t_coords *coords, int size)
{
t_coords *arr;
int i;
i = 0;
arr = coords;
while (i != size - 1)
{
if (arr[i].y > arr[i + 1].y)
{
ft_swap(&arr[i].y, &arr[i + 1].y);
i = 0;
}
else
{
i++;
}
}
return (arr);
}