-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patht_stack_list.c
More file actions
38 lines (34 loc) · 804 Bytes
/
t_stack_list.c
File metadata and controls
38 lines (34 loc) · 804 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#include <stdio.h>
#include <stdlib.h>
#include "t_cell.h"
#include "t_std_list.h"
#include "t_stack_list.h"
t_stack_list createEmptyStacklist() {
t_stack_list s;
s.head = NULL;
return s;
}
void stacklist(t_stack_list *ps, int val) {
t_cell *pn = CreateCell(val);
pn->next = ps->head;
ps->head = pn;
}
int unstacklist(t_stack_list *ps) {
if (ps->head == NULL) {
return -1; // Indiquer que la pile est vide
}
t_cell *temp = ps->head;
int val = temp->value;
ps->head = ps->head->next;
free(temp);
return val;
}
void displayStacklist(t_stack_list s) {
t_cell *cur = s.head;
printf("[ ");
while (cur != NULL) {
printf("%d ", cur->value);
cur = cur->next;
}
printf("]");
}