-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex_position.c
33 lines (30 loc) · 1.17 KB
/
index_position.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* index_position.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: pmaimait <marvin@42.fr> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2022/09/12 10:35:33 by pmaimait #+# #+# */
/* Updated: 2022/09/12 10:36:01 by pmaimait ### ########.fr */
/* */
/* ************************************************************************** */
#include "push_swap.h"
void assign_index(t_stack **stack_a)
{
t_stack *tmp;
t_stack *tmp2;
tmp = *stack_a;
tmp2 = *stack_a;
while (tmp2)
{
while (tmp)
{
if (tmp2->value > tmp->value)
tmp2->index = tmp2->index + 1;
tmp = tmp->next;
}
tmp = *stack_a;
tmp2 = tmp2->next;
}
}