-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #23 from mendes-jv/detached2
Add integer sorting and swapping functions, refactor operation functions
- Loading branch information
Showing
6 changed files
with
66 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* ft_sort_int_arr.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: jovicto2 <jovicto2@student.42sp.org.br> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2023/12/11 11:00:40 by jovicto2 #+# #+# */ | ||
/* Updated: 2023/12/11 11:00:41 by jovicto2 ### ########.org.br */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "../includes/libft.h" | ||
|
||
void ft_sort_int_arr(int *arr, size_t size) | ||
{ | ||
size_t first_index; | ||
size_t second_index; | ||
|
||
first_index = 0; | ||
while (first_index < size) | ||
{ | ||
second_index = first_index + 1; | ||
while (second_index < size) | ||
{ | ||
if (arr[first_index] > arr[second_index]) | ||
ft_swap((arr + first_index), (arr + second_index)); | ||
second_index++; | ||
} | ||
first_index++; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/* ************************************************************************** */ | ||
/* */ | ||
/* ::: :::::::: */ | ||
/* ft_swap.c :+: :+: :+: */ | ||
/* +:+ +:+ +:+ */ | ||
/* By: jovicto2 <jovicto2@student.42sp.org.br> +#+ +:+ +#+ */ | ||
/* +#+#+#+#+#+ +#+ */ | ||
/* Created: 2023/12/11 11:00:40 by jovicto2 #+# #+# */ | ||
/* Updated: 2023/12/11 11:00:41 by jovicto2 ### ########.org.br */ | ||
/* */ | ||
/* ************************************************************************** */ | ||
|
||
#include "../includes/libft.h" | ||
|
||
void ft_swap(int *nbr1, int *nbr2) | ||
{ | ||
*nbr1 ^= *nbr2; | ||
*nbr2 ^= *nbr1; | ||
*nbr1 ^= *nbr2; | ||
} |