-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_instrection2.c
73 lines (66 loc) · 2.2 KB
/
ft_instrection2.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_instrection2.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: bel-bouz <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2019/01/15 19:38:41 by bel-bouz #+# #+# */
/* Updated: 2019/01/15 19:38:44 by bel-bouz ### ########.fr */
/* */
/* ************************************************************************** */
#include "swap.h"
void excute_rotat_a(t_pile **lst_a, int min, int *len_a, int i)
{
if (min == ((*lst_a)->prec)->value)
swap(&*lst_a, *len_a, 1);
else if ((*len_a - i) <= i)
revretation(&*lst_a, *len_a, 1);
else if (*len_a - i > i)
retation(&*lst_a, *len_a, 1);
}
void excute_rotat_b(t_pile **lst_b, int min, int *len_b, int i)
{
if (min == ((*lst_b)->prec)->value)
swap(&*lst_b, *len_b, 2);
else if ((*len_b - i) <= i)
revretation(&*lst_b, *len_b, 2);
else if (*len_b - i > i)
retation(&*lst_b, *len_b, 2);
}
void swap2(t_pile **lst_a, t_pile **lst_b, t_var *var)
{
swap(&*lst_a, var->lena, 0);
swap(&*lst_b, var->lenb, 0);
}
void rev_retat2(t_pile **lst_a, t_pile **lst_b, t_var *var)
{
revretation(&*lst_a, var->lena, 0);
revretation(&*lst_b, var->lenb, 0);
}
int swap(t_pile **pile, int len, int bl)
{
int value;
t_pile *last;
int index;
int mark_up;
if (len < 2)
return (-1);
last = *pile;
value = (*pile)->value;
mark_up = (*pile)->mark_up;
index = (*pile)->index;
(*pile)->value = ((*pile)->prec)->value;
(*pile)->mark_up = ((*pile)->prec)->mark_up;
(*pile)->index = ((*pile)->prec)->index;
*pile = (*pile)->prec;
(*pile)->value = value;
(*pile)->mark_up = mark_up;
(*pile)->index = index;
*pile = last;
if (bl == 1)
ft_putstr("sa\n");
else if (bl == 2)
ft_putstr("sb\n");
return (1);
}