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
ad38d800
Commit
ad38d800
authored
3 years ago
by
Florian Burgener
Browse files
Options
Downloads
Patches
Plain Diff
Validation exercice 1
parent
f3940e21
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
ex1/main.c
+9
-8
9 additions, 8 deletions
ex1/main.c
with
9 additions
and
8 deletions
ex1/main.c
+
9
−
8
View file @
ad38d800
/**
* @file main.c
* @author
Prénom Nom
* @author
Florian Burgener
* @brief Exercice 1
* @version 1.0
* @date 2021-12-07
...
...
@@ -9,31 +9,32 @@
*
*/
#include
<math.h>
#include
<stdbool.h>
#include
<ctype.h>
#include
<stdint.h>
#include
<stdio.h>
#include
<stdlib.h>
#include
<string.h>
#include
<ctype.h>
int
main
()
{
char
str1
[
100
];
char
str2
[
100
];
// 80 characters + 1 (null character).
char
str1
[
81
];
char
str2
[
81
];
scanf
(
"%s"
,
str1
);
scanf
(
"%s"
,
str2
);
printf
(
"%s
\n
"
,
str1
);
if
(
strlen
(
str1
)
!=
strlen
(
str2
))
{
// Strings do not have the same length.
printf
(
"
\n
distance: -1
\n
"
);
return
EXIT_FAILURE
;
}
int32_t
distance
=
0
;
// Calculation of the distance.
for
(
int32_t
i
=
0
;
i
<
(
int32_t
)
strlen
(
str1
);
i
+=
1
)
{
distance
+=
abs
(
toupper
(
str1
[
i
])
-
toupper
(
str2
[
i
]));
}
printf
(
"
\n
distance: %d
\n
"
,
distance
);
...
...
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