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
7adcfe42
Commit
7adcfe42
authored
3 years ago
by
dario.genga
Browse files
Options
Downloads
Patches
Plain Diff
Add ex1
parent
260d24e7
Branches
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.gitignore
+81
-0
81 additions, 0 deletions
.gitignore
ex1/main.c
+41
-0
41 additions, 0 deletions
ex1/main.c
ex1/makefile
+10
-0
10 additions, 0 deletions
ex1/makefile
makefile
+18
-0
18 additions, 0 deletions
makefile
with
150 additions
and
0 deletions
.gitignore
0 → 100644
+
81
−
0
View file @
7adcfe42
# Created by https://www.toptal.com/developers/gitignore/api/c,visualstudiocode
# Edit at https://www.toptal.com/developers/gitignore?templates=c,visualstudiocode
### C ###
# Prerequisites
*.d
# Object files
*.o
*.ko
*.obj
*.elf
# Linker output
*.ilk
*.map
*.exp
# Precompiled Headers
*.gch
*.pch
# Libraries
*.lib
*.a
*.la
*.lo
# Shared objects (inc. Windows DLLs)
*.dll
*.so
*.so.*
*.dylib
# Executables
*.exe
*.out
*.app
*.i*86
*.x86_64
*.hex
# Debug files
*.dSYM/
*.su
*.idb
*.pdb
# Kernel Module Compile Results
*.mod*
*.cmd
.tmp_versions/
modules.order
Module.symvers
Mkfile.old
dkms.conf
### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace
# Local History for Visual Studio Code
.history/
### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide
# Support for Project snippet scope
!.vscode/*.code-snippets
# End of https://www.toptal.com/developers/gitignore/api/c,visualstudiocode
# Custom gitignore for project
main
\ No newline at end of file
This diff is collapsed.
Click to expand it.
ex1/main.c
0 → 100644
+
41
−
0
View file @
7adcfe42
/* Author : Dario GENGA
* Date : 07.12.2021
* Description : Contrôle continue 1 - Exercice 1
*/
#include
<stdio.h>
#include
<stdlib.h>
#include
<string.h>
#include
<ctype.h>
#define MAX_WORD_LENGTH 80
int
main
()
{
char
*
word1
=
malloc
(
sizeof
(
char
)
*
MAX_WORD_LENGTH
);
char
*
word2
=
malloc
(
sizeof
(
char
)
*
MAX_WORD_LENGTH
);
int
distance
=
0
;
// Get the word from the user
scanf
(
"%s"
,
word1
);
scanf
(
"%s"
,
word2
);
if
(
strlen
(
word1
)
!=
strlen
(
word2
))
{
// The words must have the same length
distance
=
-
1
;
}
else
{
// Compute the distance of each letters
for
(
size_t
i
=
0
;
i
<
strlen
(
word1
);
i
++
)
{
int
distance_tmp
=
tolower
(
word1
[
i
])
-
tolower
(
word2
[
i
]);
if
(
distance_tmp
<
0
)
{
distance_tmp
=
-
distance_tmp
;
}
distance
+=
distance_tmp
;
}
}
// Print the result and free the memory
printf
(
"
\n
distance : %d
\n
"
,
distance
);
free
(
word1
);
free
(
word2
);
return
EXIT_SUCCESS
;
}
This diff is collapsed.
Click to expand it.
ex1/makefile
0 → 100644
+
10
−
0
View file @
7adcfe42
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.
makefile
0 → 100644
+
18
−
0
View file @
7adcfe42
LIB
=
-lm
CC
=
gcc
-Wall
-Wextra
-pedantic
-g
matrix
:
matrix.o main.o
$(
CC
)
$^
-fsanitize
=
address
-fsanitize
=
leak
-o
$@
$(
LIB
)
run_tests
:
tests
./
$<
tests
:
test.o matrix.o
$(
CC
)
$^
-fsanitize
=
address
-fsanitize
=
leak
-o
$@
$(
LIB
)
matrix.o
:
matrix.c matrix.h
$(
CC
)
-c
$<
$(
LIB
)
main.o
:
main.c
$(
CC
)
-c
$<
$(
LIB
)
clean
:
rm
-f
*
.o matrix tests
\ 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