mirror of
https://github.com/DavidGailleton/42-Push_Swap.git
synced 2026-01-27 08:41:58 +00:00
finish the pos of flags
This commit is contained in:
@@ -18,6 +18,7 @@ void simple(t_stacks *piles)
|
|||||||
int len;
|
int len;
|
||||||
|
|
||||||
len = stack_a_len(piles);
|
len = stack_a_len(piles);
|
||||||
|
piles->algo = 1;
|
||||||
insertion(piles, len);
|
insertion(piles, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -26,6 +27,7 @@ void medium(t_stacks *piles)
|
|||||||
t_tab *buckets;
|
t_tab *buckets;
|
||||||
int range;
|
int range;
|
||||||
|
|
||||||
|
piles->algo = 2;
|
||||||
range = range_bucket(piles->a);
|
range = range_bucket(piles->a);
|
||||||
buckets = get_tabs(piles->a, range);
|
buckets = get_tabs(piles->a, range);
|
||||||
bucket_algo(piles, buckets, range);
|
bucket_algo(piles, buckets, range);
|
||||||
@@ -33,7 +35,8 @@ void medium(t_stacks *piles)
|
|||||||
|
|
||||||
void complex(t_stacks *piles)
|
void complex(t_stacks *piles)
|
||||||
{
|
{
|
||||||
return ;
|
piles->algo = 3;
|
||||||
|
radix(piles);
|
||||||
}
|
}
|
||||||
|
|
||||||
void adaptive(t_stacks *piles)
|
void adaptive(t_stacks *piles)
|
||||||
|
|||||||
77
flags/flag.c
77
flags/flag.c
@@ -13,7 +13,80 @@
|
|||||||
#include "push_swap.h"
|
#include "push_swap.h"
|
||||||
#include "parsing.h"
|
#include "parsing.h"
|
||||||
|
|
||||||
void flags(int pos, char **argv, t_stacks *piles)
|
static int verif_arg(char *argv)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
|
||||||
|
i = 0;
|
||||||
|
while (argv[i])
|
||||||
|
{
|
||||||
|
if (argv[i] == ' ')
|
||||||
|
return (1);
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int calcul_mod(int argc, char **argv)
|
||||||
|
{
|
||||||
|
int mod;
|
||||||
|
|
||||||
|
if (verif_arg(argv[argc -1]))
|
||||||
|
{
|
||||||
|
if (ft_strncmp(argv[1], "--", 2) && ft_strncmp(argv[2], "--", 2))
|
||||||
|
mod = 2;
|
||||||
|
else if (ft_strncmp(argv[1], "--", 2) && !ft_strncmp(argv[2], "--", 2))
|
||||||
|
mod = 1;
|
||||||
|
else
|
||||||
|
mod = 0;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (ft_strncmp(argv[1], "--", 2) && ft_strncmp(argv[2], "--", 2))
|
||||||
|
mod = 5;
|
||||||
|
else if (ft_strncmp(argv[1], "--", 2) && !ft_strncmp(argv[2], "--", 2))
|
||||||
|
mod = 4;
|
||||||
|
else
|
||||||
|
mod = 3;
|
||||||
|
}
|
||||||
|
return (mod);
|
||||||
|
}
|
||||||
|
|
||||||
|
int pos_flag(char **argv, int mod)
|
||||||
|
{
|
||||||
|
if (mod == 1 || mod == 4)
|
||||||
|
{
|
||||||
|
if (!ft_strncmp(argv[1], "--bench", 20))
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
else if (mod == 2 || mod == 5)
|
||||||
|
{
|
||||||
|
if (!ft_strncmp(argv[1], "--bench", 20))
|
||||||
|
return (1);
|
||||||
|
else
|
||||||
|
return (2);
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int pos_bench(char **argv, int mod)
|
||||||
|
{
|
||||||
|
if (mod == 1 || mod == 4)
|
||||||
|
{
|
||||||
|
if (ft_strncmp(argv[1], "--bench", 20))
|
||||||
|
return (1);
|
||||||
|
}
|
||||||
|
else if (mod == 2 || mod == 5)
|
||||||
|
{
|
||||||
|
if (ft_strncmp(argv[1], "--bench", 20))
|
||||||
|
return (1);
|
||||||
|
else
|
||||||
|
return (2);
|
||||||
|
}
|
||||||
|
return (0);
|
||||||
|
}
|
||||||
|
|
||||||
|
void flags(int pos, int pos_b, char **argv, t_stacks *piles)
|
||||||
{
|
{
|
||||||
if (ft_strncmp(argv[pos], "--simple", 30) && pos > 0)
|
if (ft_strncmp(argv[pos], "--simple", 30) && pos > 0)
|
||||||
simple(piles);
|
simple(piles);
|
||||||
@@ -25,4 +98,6 @@ void flags(int pos, char **argv, t_stacks *piles)
|
|||||||
adaptive(piles);
|
adaptive(piles);
|
||||||
else
|
else
|
||||||
adaptive(piles);
|
adaptive(piles);
|
||||||
|
if (pos_b > 0)
|
||||||
|
piles->bench = 1;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,9 @@ void simple(t_stacks *piles);
|
|||||||
void medium(t_stacks *piles);
|
void medium(t_stacks *piles);
|
||||||
void complex(t_stacks *piles);
|
void complex(t_stacks *piles);
|
||||||
void adaptive(t_stacks *piles);
|
void adaptive(t_stacks *piles);
|
||||||
void flags(int pos, char **argv, t_stacks *piles);
|
void flags(int pos, int pos_b, char **argv, t_stacks *piles);
|
||||||
|
int pos_bench(char **argv, int mod);
|
||||||
|
int pos_flag(char **argv, int mod);
|
||||||
|
int calcul_mod(int argc, char **argv);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user