test
This commit is contained in:
parent
e72a8503d9
commit
9a07f6e8f7
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