-
Notifications
You must be signed in to change notification settings - Fork 0
/
push_swap.c
39 lines (35 loc) · 1.25 KB
/
push_swap.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* push_swap.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: omkuzu <omkuzu@student.42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/12/17 20:16:46 by omkuzu #+# #+# */
/* Updated: 2024/12/17 20:16:47 by omkuzu ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
void sa(t_stack *a)
{
if (a->top > 0)
{
int temp = a->data[a->top];
a->data[a->top] = a->data[a->top - 1];
a->data[a->top - 1] = temp;
}
}
void pb(t_stack *a, t_stack *b)
{
if (a->top >= 0)
{
push(b, pop(a));
}
}
void pa(t_stack *a, t_stack *b)
{
if (b->top >= 0)
{
push(a, pop(b));
}
}