-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathoperations_bis_checker.c
executable file
·82 lines (73 loc) · 1.64 KB
/
operations_bis_checker.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* operations_bis_checker.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: abadidi < abadidi@student.1337.ma> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/02/22 21:36:21 by abadidi #+# #+# */
/* Updated: 2022/02/23 09:47:27 by abadidi ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
void rotate_stack(t_stack **s)
{
t_stack *tmp;
if (*s == NULL)
return ;
tmp = *s;
while (tmp->next)
{
tmp = tmp->next;
}
tmp->next = *s;
*s = (*s)->next;
tmp->next->next = NULL;
}
void revers_rotate(t_stack **s)
{
t_stack *last;
t_stack *before_last;
if (*s == NULL)
return ;
last = *s;
while (last->next)
{
before_last = last;
last = last->next;
}
last->next = *s;
*s = last;
before_last->next = NULL;
}
int stack_size(t_stack *s)
{
t_stack *tmp;
int i;
i = 0;
tmp = s;
while (tmp)
{
i++;
tmp = tmp->next;
}
return (i);
}
int checkduplicated(int *t, int size)
{
int i;
int j;
i = 0;
while (i < size)
{
j = i + 1;
while (j < size)
{
if (t[i] == t[j])
return (1);
j++;
}
i++;
}
return (0);
}