Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
controle-c-001
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
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
florian.burgener
controle-c-001
Commits
95bd3531
Commit
95bd3531
authored
3 years ago
by
Florian Burgener
Browse files
Options
Downloads
Patches
Plain Diff
Validation exercice 4
parent
d40041b1
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ex4/main.c
+8
-6
8 additions, 6 deletions
ex4/main.c
with
8 additions
and
6 deletions
ex4/main.c
+
8
−
6
View file @
95bd3531
/**
* @file main.c
* @author
Prénom Nom
* @brief Exercice
1
* @author
Florian Burgener
* @brief Exercice
4
* @version 1.0
* @date 2021-12-07
*
...
...
@@ -9,12 +9,9 @@
*
*/
#include
<math.h>
#include
<stdbool.h>
#include
<stdint.h>
#include
<stdio.h>
#include
<stdlib.h>
#include
<string.h>
#include
"stack.h"
...
...
@@ -22,18 +19,21 @@ int main() {
int32_t
tab_length
=
7
;
double
tab
[
tab_length
];
// Retrieves the input numbers.
for
(
int32_t
i
=
0
;
i
<
tab_length
;
i
+=
1
)
{
double
number
;
scanf
(
"%lf"
,
&
number
);
tab
[
i
]
=
number
;
}
// Initialization of the algorithm.
int32_t
interv
[
tab_length
];
interv
[
0
]
=
1
;
stack
s
;
stack_init
(
&
s
,
1000
);
stack_init
(
&
s
,
tab_length
);
stack_push
(
&
s
,
0
);
// For each number in tab.
for
(
int32_t
i
=
0
;
i
<
tab_length
;
i
+=
1
)
{
while
(
true
)
{
int32_t
top_value
;
...
...
@@ -46,6 +46,7 @@ int main() {
stack_pop
(
&
s
,
&
top_value
);
}
// Sets interv[i]
if
(
stack_is_empty
(
s
))
{
interv
[
i
]
=
i
+
1
;
}
else
{
...
...
@@ -59,6 +60,7 @@ int main() {
printf
(
"
\n
"
);
// Displays the interv array.
for
(
int32_t
i
=
0
;
i
<
tab_length
;
i
+=
1
)
{
printf
(
"%d
\n
"
,
interv
[
i
]);
}
...
...
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