-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils3.c
52 lines (46 loc) · 1.39 KB
/
utils3.c
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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* utils3.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: earnaud <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2021/07/16 16:27:26 by earnaud #+# #+# */
/* Updated: 2021/07/16 17:00:07 by earnaud ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
void index_plus(long *stack, int *index)
{
(*index)++;
if (*index > stack_nb(stack))
*index = 0;
else if (*index < 0)
*index = stack_nb(stack);
}
void index_minus(long *stack, int *index)
{
(*index)--;
if (*index > stack_nb(stack))
*index = 0;
else if (*index < 0)
*index = stack_nb(stack);
}
int ft_abs(int x)
{
if (x < 0)
return (-x);
return (x);
}
int ft_min(int a, int b)
{
if (a < b)
return (a);
return (b);
}
int ft_max(int a, int b)
{
if (a > b)
return (a);
return (b);
}