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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
algorithmique
lib_2021_malaspinas
stack
Commits
981decc1
Commit
981decc1
authored
3 years ago
by
ines.maya
Browse files
Options
Downloads
Patches
Plain Diff
fais un main pour tester et mis les includes dans le .h et doit juste voir un truc
parent
56f989db
No related branches found
No related tags found
1 merge request
!16
Resolve "Add pop function"
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
main.c
+10
-0
10 additions, 0 deletions
main.c
stack.c
+9
-3
9 additions, 3 deletions
stack.c
stack.h
+2
-0
2 additions, 0 deletions
stack.h
with
21 additions
and
3 deletions
main.c
0 → 100644
+
10
−
0
View file @
981decc1
#include
"stack.h"
int
main
(){
stack
s
;
int
value
=
0
;
stack_init
(
&
s
);
// stack_is_empty(stack s)
stack_peek
(
s
,
&
value
);
stack_pop
(
&
s
,
&
value
);
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
stack.c
+
9
−
3
View file @
981decc1
...
...
@@ -17,11 +17,17 @@ void stack_peek(stack s, int *value){
}
// depile
void
stack_pop
(
stack
*
s
,
int
*
val
){
void
stack_pop
(
stack
*
s
,
int
*
val
ue
){
if
(
stack_is_empty
(
*
s
)){
return
;
}
*
val
=
s
->
data
[
s
->
top
];
*
val
ue
=
s
->
data
[
s
->
top
];
s
->
top
-=
1
;
printf
(
"pop : %d, top : %d
\n
"
,
s
->
data
[
s
->
top
],
s
->
top
);
// 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
);
}
}
This diff is collapsed.
Click to expand it.
stack.h
+
2
−
0
View file @
981decc1
...
...
@@ -16,4 +16,6 @@ typedef struct _stack {
void
stack_init
(
stack
*
s
);
void
stack_peek
(
stack
s
,
int
*
value
);
void
stack_pop
(
stack
*
s
,
int
*
value
);
#endif
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