Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Ants_colony_algorithm
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
agnon.kurteshi
Ants_colony_algorithm
Commits
24bc2bdb
Commit
24bc2bdb
authored
3 years ago
by
agnon.kurteshi
Browse files
Options
Downloads
Patches
Plain Diff
delete stack_stack
parent
135abc02
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
stack_stack/stack_stack.c
+0
-11
0 additions, 11 deletions
stack_stack/stack_stack.c
stack_stack/stack_stack.h
+0
-82
0 additions, 82 deletions
stack_stack/stack_stack.h
with
0 additions
and
93 deletions
stack_stack/stack_stack.c
deleted
100644 → 0
+
0
−
11
View file @
135abc02
#include
<stdio.h>
#include
<stdlib.h>
#include
<stdbool.h>
#include
<assert.h>
#include
"stack.h"
typedef
struct
_stack_stack
{
int
size
;
int
top
;
stack
*
data
;
}
stack_stack
;
\ No newline at end of file
This diff is collapsed.
Click to expand it.
stack_stack/stack_stack.h
deleted
100644 → 0
+
0
−
82
View file @
135abc02
#include
<stdio.h>
#include
<stdlib.h>
#include
<assert.h>
#include
"stack.h"
void
stack_init
(
stack
*
s
,
int
max_capacity
)
{
s
->
size
=
max_capacity
;
s
->
data
=
malloc
(
max_capacity
*
sizeof
(
int
));
s
->
top
=
-
1
;
}
void
print_stack
(
stack
s
)
{
if
(
stack_is_empty
(
s
)){
printf
(
"stack is empty
\n
"
);
}
else
{
for
(
int
i
=
0
;
i
<
s
.
top
+
1
;
i
++
){
printf
(
"[%d] "
,
s
.
data
[
i
]);
}
printf
(
"
\n
"
);
}
}
void
stack_push
(
stack
*
s
,
int
value
)
{
if
(
s
->
top
==
s
->
size
-
1
)
{
printf
(
"stack full
\n
"
);
return
;
}
else
{
s
->
top
++
;
s
->
data
[
s
->
top
]
=
value
;
}
}
void
stack_pop
(
stack
*
s
,
int
*
val
)
//échoue si vide
{
if
(
stack_is_empty
(
*
s
))
{
printf
(
"empty stack
\n
"
);
return
;
}
else
{
*
val
=
s
->
data
[
s
->
top
];
s
->
top
--
;
}
}
void
stack_peek
(
stack
s
,
int
*
val
)
//return the top of the stack without pooping
{
// error if stakc is empty or NULL
*
val
=
s
.
data
[
s
.
top
];
}
bool
stack_is_empty
(
stack
s
)
//check if stack is empty
{
return
s
.
top
<
0
;
}
void
stack_destroy
(
stack
*
s
)
{
s
->
top
=
-
1
;
free
(
s
->
data
);
}
void
stack_to_stack
(
stack
*
stack_emet
,
stack
*
stack_dest
)
{
if
(
stack_is_empty
(
*
stack_emet
)){
printf
(
"stack empty"
);
return
;
}
int
valeur
;
stack_pop
(
stack_emet
,
&
valeur
);
stack_push
(
stack_dest
,
valeur
);
}
\ 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