debut ecritures fonctions clean et error

This commit is contained in:
hugogogo
2021-06-10 14:20:38 +02:00
parent 8d3fb563dd
commit 64363aeb18
9 changed files with 87 additions and 22 deletions
+2 -1
View File
@@ -19,7 +19,8 @@ LDIR = ./libft
_LIBS = libft.a _LIBS = libft.a
LIBS = $(_LIBS:lib%.a=%) LIBS = $(_LIBS:lib%.a=%)
SRCS = pushswap.c SRCS = pushswap.c \
error.c
ODIR = ./builds ODIR = ./builds
OBJS = $(SRCS:%.c=$(ODIR)/%.o) OBJS = $(SRCS:%.c=$(ODIR)/%.o)
+4 -4
View File
@@ -41,10 +41,10 @@
2000 0 3 973 224 Gravity Sort 2000 0 3 973 224 Gravity Sort
2000 0 6 000 Counting Sort 2000 0 6 000 Counting Sort
2000 0 4 000 Pigeonhole Sort 2000 0 4 000 Pigeonhole Sort
Radix LSD Sort (Base 4) 2000 0 12 000 Radix LSD Sort (Base 4)
American Flag Sort (128 Buckets) 2000 0 4 220 American Flag Sort (128 Buckets)
Radix LSD In-Place Sort (Base 10) 2048 0 19 207 376 Radix LSD In-Place Sort (Base 10)
Radix LSD In-Place Sort (Base 2) 2000 0 34 562 144 Radix LSD In-Place Sort (Base 2)
Radix MSD Sort (Base 4) Radix MSD Sort (Base 4)
Radix MSD Sort (Base 2) Radix MSD Sort (Base 2)
Shatter Sort Shatter Sort
BIN
View File
Binary file not shown.
BIN
View File
Binary file not shown.
+14 -4
View File
@@ -1,48 +1,58 @@
#ifndef PUSH_SWAP_H #ifndef PUSH_SWAP_H
# define PUSH_SWAP_H # define PUSH_SWAP_H
# include "libft.h" # include "../libft/includes/libft.h"
// # include "../libft/includes/libft.h"
# include <unistd.h> // read(), write(), sleep() # include <unistd.h> // read(), write(), sleep()
# include <stdlib.h> // malloc(), free(), exit(), atoi() # include <stdlib.h> // malloc(), free(), exit(), atoi()
typedef struct s_list typedef struct s_stack
{ {
int n; int n;
struct s_list *next; struct s_list *next;
} t_list; } t_stack;
void ps_error(int i);
void ps_clean(t_stack *stack, int i);
/* /*
** swap ** swap
*/ */
/*
int swap(t_list **list); int swap(t_list **list);
int sa(); int sa();
int sb(); int sb();
int ss(); int ss();
*/
/* /*
** push ** push
*/ */
/*
int push(t_list **dst, t_list **src); int push(t_list **dst, t_list **src);
int pa(); int pa();
int pb(); int pb();
int pp(); int pp();
*/
/* /*
** rotate ** rotate
*/ */
/*
int rotate(t_list **list); int rotate(t_list **list);
int ra(); int ra();
int rb(); int rb();
int rr(); int rr();
*/
/* /*
** reverse rotate ** reverse rotate
*/ */
/*
int reverse_rotate(t_list **list); int reverse_rotate(t_list **list);
int rra(); int rra();
int rrb(); int rrb();
int rrr(); int rrr();
*/
#endif #endif
Executable
BIN
View File
Binary file not shown.
Binary file not shown.
+22
View File
@@ -0,0 +1,22 @@
#include "pushswap.h"
void ps_clean(t_stack *stack, int err)
{
(void)stack;
ps_error(err);
}
void ps_usage(void)
{
ft_printf("usage\n");
}
void ps_error(int err)
{
if (err == 1)
ps_usage();
if (err == 2)
ft_printf("error\n");
exit(0);
}
+32
View File
@@ -0,0 +1,32 @@
#include "pushswap.h"
void is_valid(int ac, char **av)
{
if (ac < 2)
ps_error(1);
(void)av;
}
t_stack *init_stack(int ac, char **av)
{
(void)ac;
(void)av;
t_stack *start;
if (!(start = ft_calloc(1, sizeof(t_stack))))
ps_clean(start, 2);
return (start);
}
int main(int ac, char **av)
{
t_stack *stack;
//t_list *result;
is_valid(ac, av); // check if usage and list are correct
stack = init_stack(ac, av);
// result = sort_algo(stack);
return(0);
}