typedef for the moves function array
This commit is contained in:
parent
a84e797e89
commit
607ce0db6a
4
Makefile
4
Makefile
@ -41,7 +41,7 @@ CC = cc
|
|||||||
RM = rm -rf
|
RM = rm -rf
|
||||||
|
|
||||||
INCLUDES = -I./$(INC_PATH) -I./$(LIBFT_INC_PATH)
|
INCLUDES = -I./$(INC_PATH) -I./$(LIBFT_INC_PATH)
|
||||||
CFLAGS = -Wall -Wextra -Werror -g
|
CFLAGS = -Wall -Wextra -Werror
|
||||||
LDFLAGS = -L./libft
|
LDFLAGS = -L./libft
|
||||||
LDLIBS = -lft
|
LDLIBS = -lft
|
||||||
|
|
||||||
@ -89,4 +89,4 @@ debug: fclean
|
|||||||
@$(MAKE) -C libft debug
|
@$(MAKE) -C libft debug
|
||||||
@$(MAKE) -s
|
@$(MAKE) -s
|
||||||
|
|
||||||
.PHONY: all bonus clean fclean re
|
.PHONY: all bonus clean fclean re run debug
|
||||||
|
|||||||
@ -21,6 +21,8 @@ typedef struct s_state
|
|||||||
t_list *b;
|
t_list *b;
|
||||||
} t_state;
|
} t_state;
|
||||||
|
|
||||||
|
typedef void (*t_move)(t_state *, int);
|
||||||
|
|
||||||
int *longest_incremental_subsequence(t_list *stack, int *lis_size);
|
int *longest_incremental_subsequence(t_list *stack, int *lis_size);
|
||||||
int *lis_lengths(t_list *stack, int size);
|
int *lis_lengths(t_list *stack, int size);
|
||||||
int *lis_indices(int *lengths, int size, int max_len);
|
int *lis_indices(int *lengths, int size, int max_len);
|
||||||
|
|||||||
@ -16,10 +16,12 @@
|
|||||||
|
|
||||||
void execute_move(const char *move, t_state *state)
|
void execute_move(const char *move, t_state *state)
|
||||||
{
|
{
|
||||||
void (*const moves[])(t_state *, int) = {&sa, &sb, &ss, &pa, &pb, \
|
const t_move moves[11] = {&sa, &sb, &ss, &pa, &pb, \
|
||||||
&ra, &rb, &rr, &rra, &rrb, &rrr};
|
&ra, &rb, &rr, &rra, &rrb, &rrr};
|
||||||
const char *moves_names[] = {"sa\n", "sb\n", "ss\n", "pa\n", "pb\n", \
|
const char *moves_names[] = {"sa\n", "sb\n", "ss\n", \
|
||||||
"ra\n", "rb\n", "rr\n", "rra\n", "rrb\n", "rrr\n"};
|
"pa\n", "pb\n", \
|
||||||
|
"ra\n", "rb\n", "rr\n", \
|
||||||
|
"rra\n", "rrb\n", "rrr\n"};
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
i = 0;
|
i = 0;
|
||||||
@ -47,9 +49,9 @@ int main(int argc, char *argv[])
|
|||||||
{
|
{
|
||||||
if (!new_element(&(state->a), argv[argc]))
|
if (!new_element(&(state->a), argv[argc]))
|
||||||
return (error(state));
|
return (error(state));
|
||||||
|
}
|
||||||
if (has_duplicates(state->a))
|
if (has_duplicates(state->a))
|
||||||
return (error(state));
|
return (error(state));
|
||||||
}
|
|
||||||
size = ft_lstsize(state->a);
|
size = ft_lstsize(state->a);
|
||||||
move = get_next_line(STDIN_FILENO);
|
move = get_next_line(STDIN_FILENO);
|
||||||
while (move)
|
while (move)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user