Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /* ************************************************************************** */
- /* */
- /* ::: :::::::: */
- /* sort_int_tab.c :+: :+: :+: */
- /* +:+ +:+ +:+ */
- /* By: exam <marvin@42.fr> +#+ +:+ +#+ */
- /* +#+#+#+#+#+ +#+ */
- /* Created: 2018/06/19 10:01:14 by exam #+# #+# */
- /* Updated: 2018/06/19 10:23:34 by exam ### ########.fr */
- /* */
- /* ************************************************************************** */
- void ft_swap(int *a, int *b)
- {
- int tmp = *a;
- *a = *b;
- *b = tmp;
- }
- void sort_int_tab(int *tab, unsigned int size)
- {
- unsigned int i = 0;
- int a = 0;
- while(i < size)
- {
- if(tab[i] > tab [i + 1])
- {
- ft_swap(&tab[i],&tab[i + 1]);
- a = i;
- }
- while(a)
- {
- if(tab[a] < tab[a - 1])
- {
- ft_swap(&tab[a], &tab[a - 1]);
- a--;
- }
- else
- a = 0;
- }
- i++;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement