-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreverse.c
62 lines (56 loc) · 1.61 KB
/
reverse.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
53
54
55
56
57
58
59
60
61
62
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* reverse.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: wdelaros <wdelaros@student.42quebec.com +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/01/18 07:36:53 by wdelaros #+# #+# */
/* Updated: 2023/03/20 09:43:59 by wdelaros ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
void rra(t_pile *a, int bool)
{
int tmp;
int arraytmp;
while (a->next != NULL)
a = a->next;
tmp = a->nbr;
arraytmp = a->array;
while (a->previous != NULL)
{
a->nbr = a->previous->nbr;
a->array = a->previous->array;
a = a->previous;
}
a->nbr = tmp;
a->array = arraytmp;
if (bool)
write(1, "rra\n", 4);
}
void rrb(t_pile *b, int bool)
{
int tmp;
int arraytmp;
while (b->next != NULL)
b = b->next;
tmp = b->nbr;
arraytmp = b->array;
while (b->previous != NULL)
{
b->nbr = b->previous->nbr;
b->array = b->previous->array;
b = b->previous;
}
b->nbr = tmp;
b->array = arraytmp;
if (bool)
write(1, "rrb\n", 4);
}
void rrr(t_pile *a, t_pile *b)
{
rra(a, 0);
rrb(b, 0);
write(1, "rrr\n", 4);
}