-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrra_rrb.c
97 lines (86 loc) · 1.96 KB
/
rra_rrb.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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* rra_rrb.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: atyurina <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2024/01/05 14:59:31 by atyurina #+# #+# */
/* Updated: 2024/01/11 12:28:24 by atyurina ### ########.fr */
/* */
/* ************************************************************************** */
//нижний элемент идет на самый верх,
//остальные опускаются на один шаг
#include "push_swap.h"
void rra(long int *a, int a_len)
{
long int temp;
int i;
if (a_len > 1)
{
temp = a[a_len - 1];
i = a_len - 1;
while (i > 0)
{
a[i] = a[i - 1];
i--;
}
a[0] = temp;
ft_putstr("rra\n");
}
}
void rrb(long int *a, int a_len)
{
long int temp;
int i;
if (a_len > 1)
{
temp = a[a_len - 1];
i = a_len - 1;
while (i > 0)
{
a[i] = a[i - 1];
i--;
}
a[0] = temp;
ft_putstr("rrb\n");
}
}
static void rra_rrr(long int *a, int a_len)
{
long int temp;
int i;
if (a_len > 1)
{
temp = a[a_len - 1];
i = a_len - 1;
while (i > 0)
{
a[i] = a[i - 1];
i--;
}
a[0] = temp;
}
}
static void rrb_rrr(long int *a, int a_len)
{
long int temp;
int i;
if (a_len > 1)
{
temp = a[a_len - 1];
i = a_len - 1;
while (i > 0)
{
a[i] = a[i - 1];
i--;
}
a[0] = temp;
}
}
void rrr(long int *a, long int *b, int a_len, int b_len)
{
rra_rrr(a, a_len);
rrb_rrr(b, b_len);
ft_putstr("rrr\n");
}