-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstructions.c
64 lines (56 loc) · 1.46 KB
/
instructions.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* instructions.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: lhenneca <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2020/01/11 14:08:15 by lhenneca #+# #+# */
/* Updated: 2020/02/03 15:57:23 by lhenneca ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
int swap(int *tab, int len)
{
int temp;
if (len < 2)
return (-1);
temp = tab[len];
tab[len] = tab[len -1];
tab[len - 1] = temp;
return (0);
}
int push(int *a, int *b, int lena, int lenb)
{
a[lena] = b[lenb - 1];
b[lenb - 1] = '\0';
return (0);
}
int rot(int *a, int len)
{
int i;
int temp;
i = 0;
temp = a[i];
while (i < len - 2)
{
i++;
a[i] = a[i + 1];
}
a[i] = temp;
return (0);
}
int rot_rev(int *a, int len)
{
int i;
int temp;
i = len - 1;
temp = a[i];
while (i > 1)
{
i--;
a[i] = a[i - 1];
}
a[i] = temp;
return (0);
}