diff --git a/tp7/exo7.c b/tp7/exo7.c new file mode 100644 index 0000000..e86e162 --- /dev/null +++ b/tp7/exo7.c @@ -0,0 +1,21 @@ +#include +#include + +// Pile with size at index 0 +int* creer_pileb(int capacite) { + int* b = malloc((capacite+1)*sizeof(int)); + b[0] = 0; + return b; +} +// User must make sure that the size isn't bigger than capacity +void empiler_pileb(int* p, int x) { + p[p[0]+1] = x; + p[0]++; +} +int depiler_pileb(int* p) { + p[0]--; + return p[p[0]+1]; +} +bool est_vide_pileb(int* p) { + return p[0] <= 0; +}