sort_int_tab.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /* ************************************************************************** */
  2. /* */
  3. /* ::: :::::::: */
  4. /* sort_int_tab.c :+: :+: :+: */
  5. /* +:+ +:+ +:+ */
  6. /* By: mazimi <marvin@42.fr> +#+ +:+ +#+ */
  7. /* +#+#+#+#+#+ +#+ */
  8. /* Created: 2015/12/17 15:27:13 by mazimi #+# #+# */
  9. /* Updated: 2015/12/17 15:52:46 by mazimi ### ########.fr */
  10. /* */
  11. /* ************************************************************************** */
  12. #include "../libft.h"
  13. void sort_int_tab(int *tab, unsigned int size)
  14. {
  15. int tmp;
  16. int sorted;
  17. unsigned int i;
  18. sorted = 0;
  19. while (sorted != 1)
  20. {
  21. sorted = 1;
  22. i = -1;
  23. while (++i < size - 1)
  24. if (tab[i] > tab[i + 1])
  25. {
  26. tmp = tab[i];
  27. tab[i] = tab[i + 1];
  28. tab[i + 1] = tmp;
  29. sorted = 0;
  30. }
  31. }
  32. }