#include <stdio.h>

void swap(int *a, int *b)
{
    int tmp;

    tmp = *a;
    *a = *b;
    *b = tmp;
}

void sort_int_tab(int *tab, unsigned int size)
{
    int i = 0;
    //int swapped = 1

    while (i < (size - 1))
        {
            if (tab[i] > tab[i + 1])
            {
                swap(&tab[i], &tab[i + 1]);
                i = 0;
            }
            else // a retenir ici la feinte
                i++;                
        }
}

int main() 
{
    int tab[] = {10, -20, 0, 25, -50};
    unsigned int size = 5;

    int i = 0;

    sort_int_tab(tab, size);
    while (i < size)
        {
            printf("La valeur de du tableau trié est: %d \n", tab[i]);
            i++;
        }
    printf("\n");
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: