-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrules_one.c
More file actions
86 lines (78 loc) · 1.9 KB
/
rules_one.c
File metadata and controls
86 lines (78 loc) · 1.9 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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* rules_one.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bhielsch <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/12/15 12:37:28 by bhielsch #+# #+# */
/* Updated: 2022/12/15 12:37:29 by bhielsch ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
void sa(t_stack *stack, int ind)
{
int temp;
temp = 0;
if (stack->ca > 1)
{
temp = stack->stcka[0];
stack->stcka[0] = stack->stcka[1];
stack->stcka[1] = temp;
}
if (ind == 1)
ft_printf("ss\n");
else
{
ft_printf("sa\n");
stack->m_c++;
}
}
void sb(t_stack *stack, int ind)
{
int temp;
temp = 0;
if (stack->cb > 1)
{
temp = stack->stckb[0];
stack->stckb[0] = stack->stckb[1];
stack->stckb[1] = temp;
}
if (ind == 1)
ft_printf("ss\n");
else
{
ft_printf("sb\n");
stack->m_c++;
}
}
void ss(t_stack *stack)
{
sa(stack, 1);
sb(stack, 1);
stack->m_c++;
}
void pa(t_stack *stack)
{
if (stack->cb > 0)
{
stack->ca = stack->ca + 1;
move_stack_down(stack, 'a');
stack->stcka[0] = stack->stckb[0];
move_stack_up(stack, 'b');
}
ft_printf("pa\n");
stack->m_c++;
}
void pb(t_stack *stack)
{
if (stack->ca > 0)
{
stack->cb = stack->cb + 1;
move_stack_down(stack, 'b');
stack->stckb[0] = stack->stcka[0];
move_stack_up(stack, 'a');
}
ft_printf("pb\n");
stack->m_c++;
}