mirror of
https://github.com/DavidGailleton/42-Push_Swap.git
synced 2026-01-27 00:41:57 +00:00
finish the disorder
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
/* ************************************************************************** */
|
||||
|
||||
#include "push_swap.h"
|
||||
#include "parsing.h"
|
||||
|
||||
static int strs_len(char **strs)
|
||||
{
|
||||
@@ -22,7 +23,7 @@ static int strs_len(char **strs)
|
||||
return (i);
|
||||
}
|
||||
|
||||
float compute_disorder(char **strs)
|
||||
float compute_disorder(char **strs, int pos)
|
||||
{
|
||||
float mistakes;
|
||||
float total_pairs;
|
||||
@@ -31,14 +32,14 @@ float compute_disorder(char **strs)
|
||||
|
||||
mistakes = 0;
|
||||
total_pairs = 0;
|
||||
i = 0;
|
||||
i = pos;
|
||||
while (i < strs_len(strs))
|
||||
{
|
||||
j = i + 1;
|
||||
while (j < strs_len(strs))
|
||||
{
|
||||
total_pairs += 1;
|
||||
if (strs[i] > strs[j])
|
||||
if (ft_atoi(strs[i]) > ft_atoi(strs[j]))
|
||||
mistakes += 1;
|
||||
j++;
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
char *ft_strjoin(char const *s1, char const *s2)
|
||||
{
|
||||
int total_len;
|
||||
int total_len;
|
||||
char *tmp;
|
||||
|
||||
total_len = ft_strlen(s1) + ft_strlen(s2);
|
||||
|
||||
Reference in New Issue
Block a user