Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
P
progseq-controle_continue_1
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
dario.genga
progseq-controle_continue_1
Commits
59f43730
Commit
59f43730
authored
3 years ago
by
dario.genga
Browse files
Options
Downloads
Patches
Plain Diff
Add non finished ex3
parent
7adcfe42
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
ex1/main.c
+1
-1
1 addition, 1 deletion
ex1/main.c
ex3/main.c
+41
-0
41 additions, 0 deletions
ex3/main.c
ex3/makefile
+10
-0
10 additions, 0 deletions
ex3/makefile
with
52 additions
and
1 deletion
ex1/main.c
+
1
−
1
View file @
59f43730
...
@@ -32,7 +32,7 @@ int main() {
...
@@ -32,7 +32,7 @@ int main() {
}
}
}
}
// Print the result and free the memory
// Print the result and free the memory
printf
(
"
\n
distance
: %d
\n
"
,
distance
);
printf
(
"
\n
distance: %d
\n
"
,
distance
);
free
(
word1
);
free
(
word1
);
free
(
word2
);
free
(
word2
);
...
...
This diff is collapsed.
Click to expand it.
ex3/main.c
0 → 100644
+
41
−
0
View file @
59f43730
/* Author : Dario GENGA
* Date : 07.12.2021
* Description : Contrôle continue 1 - Exercice 3
*/
#include
<stdio.h>
#include
<stdlib.h>
#define ARRAY_SIZE 3
int
main
()
{
int
value
=
0
;
int
result
=
0
;
int
money
[
ARRAY_SIZE
]
=
{
10
,
2
,
1
};
scanf
(
"%d"
,
&
value
);
for
(
int
i
=
0
;
i
<
ARRAY_SIZE
;
i
++
)
{
int
sub_index
=
i
;
int
rest
=
value
;
int
quotient
=
value
/
money
[
i
];
if
(
quotient
>
0
)
{
for
(
int
k
=
1
;
k
<=
quotient
;
k
++
)
{
while
(
rest
!=
0
&&
sub_index
<
ARRAY_SIZE
)
{
int
current_money
=
k
*
money
[
sub_index
];
rest
=
rest
%
current_money
;
sub_index
++
;
}
if
(
rest
==
0
)
{
result
++
;
rest
=
value
;
sub_index
=
i
;
}
}
}
}
printf
(
"
\n
%d
\n
"
,
result
);
return
EXIT_SUCCESS
;
}
This diff is collapsed.
Click to expand it.
ex3/makefile
0 → 100644
+
10
−
0
View file @
59f43730
LIB
=
-lm
CC
=
gcc
-Wall
-Wextra
-pedantic
-g
main
:
main.o
$(
CC
)
$^
-fsanitize
=
address
-fsanitize
=
leak
-o
$@
$(
LIB
)
main.o
:
main.c
$(
CC
)
-c
$<
$(
LIB
)
clean
:
rm
-f
*
.o main
\ 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