Skip to content
Snippets Groups Projects
Commit 6119dc9c authored by ines.maya's avatar ines.maya
Browse files

tous les test ok

parent e7553071
No related branches found
No related tags found
1 merge request!16Resolve "Add pop function"
This commit is part of merge request !16. Comments created here will be created in the context of that merge request.
......@@ -2,18 +2,16 @@
int main(){
stack s;
int value = 0;
int value = 13;
stack_init(&s);
for (int i = 0; i < s.capacity; i++){
s.top += 1;
s.data[s.top] = i;
printf("push : %d\n", s.data[s.top]);
}
s.data[s.top] = value;
s.top += 1;
s.data[s.top] = value+1;
// stack_is_empty(stack s)
stack_pop(&s, &value);
stack_peek(s, &value);
free(s.data);
s.data = NULL;
......
......@@ -14,6 +14,7 @@ void stack_peek(stack s, int *value){
if (!stack_is_empty(s)) {
*value = s.data[s.top];
}
printf("peek : value %d, top : %d\n", s.data[s.top],s.top);
}
// depile
......@@ -29,10 +30,4 @@ void stack_pop(stack *s, int *value){
*value = s->data[s->top];
printf("pop : %d, top : %d\n", s->data[s->top],s->top);
s->top -= 1;
// // si capacite 2x trop grande, on la rend plus petite
// if (s->capacity > 2*s->top){
// s->capacity = s->top;
// s->data = realloc(s, sizeof(int)*s->capacity);
// }
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment