void myswap(int *tab, int i);
void sort_int_tab(int *tab, unsigned int size);
void myswap(int *tab, int i)
{
int tmp;
tmp = tab[i];
tab[i] = tab[i +1];
tab[i + 1] = tmp;
}
void sort_int_tab(int *tab, unsigned int size)
{
int i = 0;
while (i < (size -1))
{
if (tab[i] > tab[i + 1])
{
myswap(tab, i); // pas de tab[i], ici on pase le ptr vers un tableau
i = 0;
}
else
i++;
}
}
#include <stdio.h>
int main()
{
int tab[]={8, 10, -5, 0, 2};
unsigned int size = 5;
int i = 0;
sort_int_tab(tab, size);
while (i < size)
{
printf("%d;", tab[i]);
i++;
}
printf("\n");
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: