This commit is contained in:
Arkitu 2026-01-15 21:14:31 +01:00
parent 9aad4d3cba
commit 078f1b96c0

21
tp7/exo7.c Normal file
View File

@ -0,0 +1,21 @@
#include <stdbool.h>
#include <stdlib.h>
// 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;
}