#include <stdio.h>

// Déclaration de la fonction de tri
void	ft_sort_int_tab(int *tab, int size)
{
	int	aux;
	int	i;
	int	j;

	i = 0;
	while (i < size)
	{
		j = i + 1;
		while (j < size)
		{
			if (tab[i] > tab[j])
			{
				aux = tab[i];
				tab[i] = tab[j];
				tab[j] = aux;
			}
			j++;
		}
		i++;
	}
}

// Fonction main pour tester le tri
int	main(void)
{
	int tab[] = {42, 15, 73, 3, 90, 25};
	int size = 6;

	// Affichage du tableau avant le tri
	printf("Tableau avant le tri :\n");
	for (int i = 0; i < size; i++)
	{
		printf("%d ", tab[i]);
	}
	printf("\n");

	// Appel de la fonction de tri
	ft_sort_int_tab(tab, size);

	// Affichage du tableau après le tri
	printf("Tableau après le tri :\n");
	for (int i = 0; i < size; i++)
	{
		printf("%d ", tab[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: