-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutils2.c
73 lines (66 loc) · 1.85 KB
/
utils2.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
63
64
65
66
67
68
69
70
71
72
73
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* utils2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: arasal <arasal@student.42heilbronn.de> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/05/24 17:20:48 by arasal #+# #+# */
/* Updated: 2022/06/06 05:13:06 by arasal ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
void ra(t_stack **a)
{
t_stack *new;
t_stack *temp;
if (*a == NULL || (*a)->next == NULL)
return ;
temp = (*a);
(*a) = (*a)->next;
new = (*a);
temp->next = NULL;
while (new->next != NULL)
new = new->next;
new->next = temp;
write(1, "ra\n", 3);
}
void rb(t_stack **b)
{
t_stack *new;
t_stack *temp;
if (*b == NULL || (*b)->next == NULL)
return ;
temp = (*b);
(*b) = (*b)->next;
new = (*b);
temp->next = NULL;
while (new->next != NULL)
new = new->next;
new->next = temp;
write(1, "rb\n", 3);
}
void rr(t_stack **a, t_stack **b)
{
t_stack *new;
t_stack *temp;
if (*b == NULL || (*b)->next == NULL)
return ;
if (*a == NULL || (*a)->next == NULL)
return ;
temp = (*a);
(*a) = (*a)->next;
new = (*a);
temp->next = NULL;
while (new->next != NULL)
new = new->next;
new->next = temp;
temp = (*b);
(*b) = (*b)->next;
new = (*b);
temp->next = NULL;
while (new->next != NULL)
new = new->next;
new->next = temp;
write(1, "rr\n", 3);
}