-
Notifications
You must be signed in to change notification settings - Fork 0
/
ft_sort_int_tab.c
56 lines (52 loc) · 1.38 KB
/
ft_sort_int_tab.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
/* ************************************************************************** */
/* */
/* ::: :::::::: */
/* ft_sort_int_tab.c :+: :+: :+: */
/* +:+ +:+ +:+ */
/* By: davgalle <[email protected]> +#+ +:+ +#+ */
/* +#+#+#+#+#+ +#+ */
/* Created: 2023/07/14 11:33:24 by davgalle #+# #+# */
/* Updated: 2023/07/16 17:05:01 by davgalle ### ########.fr */
/* */
/* ************************************************************************** */
#include<unistd.h>
#include<stdio.h>
void ft_sort_int_tab(int *tab, int size)
{
int i;
int j;
int aux;
i = 1;
while (i < size)
{
i++;
j = i;
aux = tab[i];
while (j > 0 && aux < tab[j - 1])
{
tab[j] = tab[j - 1];
j = j - 1;
}
tab[j] = aux;
}
i = 0;
while (i < size)
{
i++;
}
}
/*
int main(void)
{
int tab[]={1, 5, 7, 3, 5, 2, 1, 9, 7, 8, 9};
int size;
size = 11;
ft_sort_int_tab(tab, size);
size = 0;
while (size < 11)
{
printf("%d", tab[size]);
size++;
}
return (0);
}*/