Merge branch 'master' of github.com:kinou-p/Push_swap
This commit is contained in:
commit
5b48138108
37
indexing.c
Normal file
37
indexing.c
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
/* ************************************************************************** */
|
||||||
|
/* */
|
||||||
|
/* ::: :::::::: */
|
||||||
|
/* indexing.c :+: :+: :+: */
|
||||||
|
/* +:+ +:+ +:+ */
|
||||||
|
/* By: apommier <apommier@student.42.fr> +#+ +:+ +#+ */
|
||||||
|
/* +#+#+#+#+#+ +#+ */
|
||||||
|
/* Created: 2022/01/05 03:23:29 by apommier #+# #+# */
|
||||||
|
/* Updated: 2022/01/05 03:23:29 by apommier ### ########.fr */
|
||||||
|
/* */
|
||||||
|
/* ************************************************************************** */
|
||||||
|
|
||||||
|
#include "push_swap.h"
|
||||||
|
|
||||||
|
void lst_indexing(t_list *list)
|
||||||
|
{
|
||||||
|
int index;
|
||||||
|
t_list *swap;
|
||||||
|
t_list *save;
|
||||||
|
|
||||||
|
swap = list;
|
||||||
|
save = list;
|
||||||
|
index = 0;
|
||||||
|
while(save)
|
||||||
|
{
|
||||||
|
index = 1;
|
||||||
|
while (swap)
|
||||||
|
{
|
||||||
|
if (*(int*)save->nbr > *(int*)swap->nbr)
|
||||||
|
index++;
|
||||||
|
swap = swap->next;
|
||||||
|
}
|
||||||
|
save->index = index;
|
||||||
|
swap = list;
|
||||||
|
save = save->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user