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
4f002953
Commit
4f002953
authored
3 years ago
by
ines.maya
Browse files
Options
Downloads
Patches
Plain Diff
eneleve tous ceux qui est pas fonction pop
parent
6119dc9c
Branches
Branches containing commit
Tags
Tags containing commit
1 merge request
!16
Resolve "Add pop function"
Changes
4
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
Makefile
+0
-14
0 additions, 14 deletions
Makefile
main.c
+0
-20
0 additions, 20 deletions
main.c
stack.c
+12
-21
12 additions, 21 deletions
stack.c
stack.h
+0
-21
0 additions, 21 deletions
stack.h
with
12 additions
and
76 deletions
Makefile
deleted
100644 → 0
+
0
−
14
View file @
6119dc9c
CC
=
gcc
CFLAGS
=
-Wall
-Wextra
-pedantic
-g
-std
=
c11
-O3
CFLAGS_ASAN
=
-fsanitize
=
address
-fno-omit-frame-pointer
LDFLAGS
=
-lm
LDFLAGS_ASAN
=
-fsanitize
=
address
-fno-omit-frame-pointer
main
:
stack.o main.o
$(
CC
)
-o
$@
$^
$(
CFLAGS
)
$(
LDFLAGS
)
$(
LDFLAGS_ASAN
)
%.o
:
%.c
$(
CC
)
$(
CFLAGS
)
$(
CFLAGS_ASAN
)
-c
$^
-o
$@
clean
:
rm
-f
*
.o main
This diff is collapsed.
Click to expand it.
main.c
deleted
100644 → 0
+
0
−
20
View file @
6119dc9c
#include
"stack.h"
int
main
(){
stack
s
;
int
value
=
13
;
stack_init
(
&
s
);
s
.
top
+=
1
;
s
.
data
[
s
.
top
]
=
value
;
s
.
top
+=
1
;
s
.
data
[
s
.
top
]
=
value
+
1
;
stack_pop
(
&
s
,
&
value
);
free
(
s
.
data
);
s
.
data
=
NULL
;
s
.
capacity
=
-
1
;
s
.
top
=
-
1
;
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
stack.c
+
12
−
21
View file @
4f002953
#include
"stack.h"
#include
<stdio.h>
#include
<stdlib.h>
#include
<assert.h>
#include
<stdbool.h>
void
stack_init
(
stack
*
s
){
#define DEFAULT_CAPACITY 4
s
->
top
=
-
1
;
s
->
capacity
=
DEFAULT_CAPACITY
;
s
->
data
=
malloc
(
sizeof
(
int
)
*
DEFAULT_CAPACITY
);
}
bool
stack_is_empty
(
stack
s
){
return
s
.
top
==
-
1
;
}
void
stack_peek
(
stack
s
,
int
*
value
){
typedef
struct
_stack
{
if
(
!
stack_is_empty
(
s
))
{
int
*
data
;
*
value
=
s
.
data
[
s
.
top
];
int
capacity
;
}
int
top
;
printf
(
"peek : value %d, top : %d
\n
"
,
s
.
data
[
s
.
top
],
s
.
top
);
}
stack
;
}
// depile
// depile
void
stack_pop
(
stack
*
s
,
int
*
value
){
void
stack_pop
(
stack
*
s
,
int
*
value
){
if
(
stack_is_empty
(
*
s
)){
assert
(
s
->
top
>=
0
&&
"Stcak is empty
\n
"
);
return
;
}
if
(
s
->
top
==
s
->
capacity
/
4
){
if
(
s
->
top
==
s
->
capacity
/
4
){
s
->
capacity
/=
2
;
s
->
capacity
/=
2
;
}
}
*
value
=
s
->
data
[
s
->
top
];
*
value
=
s
->
data
[
s
->
top
];
printf
(
"pop : %d, top : %d
\n
"
,
s
->
data
[
s
->
top
],
s
->
top
);
s
->
top
-=
1
;
s
->
top
-=
1
;
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
stack.h
deleted
100644 → 0
+
0
−
21
View file @
6119dc9c
#ifndef _STACK_H_
#define _STACK_H_
#include
<stdio.h>
#include
<stdlib.h>
#include
"stdbool.h"
#define DEFAULT_CAPACITY 4
typedef
struct
_stack
{
int
*
data
;
int
capacity
;
int
top
;
}
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