Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Stack
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
COURS_ALGO_2024_2025
Stack
Commits
12c9a8e4
Commit
12c9a8e4
authored
6 months ago
by
thibaud
Browse files
Options
Downloads
Patches
Plain Diff
Initial commit
parents
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
stack_lib.c
+30
-0
30 additions, 0 deletions
stack_lib.c
with
30 additions
and
0 deletions
stack_lib.c
0 → 100644
+
30
−
0
View file @
12c9a8e4
#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
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment