Skip to content
Snippets Groups Projects
Commit 12c9a8e4 authored by thibaud's avatar thibaud
Browse files

Initial commit

parents
Branches
No related tags found
No related merge requests found
#include <stdbool.h>
#define MAX_CAPACITY 500
typedef struct _stack {
int data[MAX_CAPACITY]; // les données
int top; // indice du sommet
} stack;
void stack_init(stack *s) {
s->top = -1;
}
bool stack_is_empty(stack s) {
return s.top == -1;
}
void stack_push(stack *s, int val) {
s->top += 1;
s->data[s->top] = val;
}
int stack_pop(stack *s) {
s->top -= 1;
return s->data[s->top+1];
}
int stack_peek(stack s) {
return s.data[s.top];
}
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment