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
f3940e21
Commit
f3940e21
authored
3 years ago
by
Florian Burgener
Browse files
Options
Downloads
Patches
Plain Diff
Validation exercice 2
parent
4d5db955
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
ex2/main.c
+17
-10
17 additions, 10 deletions
ex2/main.c
with
17 additions
and
10 deletions
ex2/main.c
+
17
−
10
View file @
f3940e21
/**
* @file main.c
* @author
Prénom Nom
* @brief Exercice
1
* @author
Florian Burgener
* @brief Exercice
2
* @version 1.0
* @date 2021-12-07
*
...
...
@@ -9,16 +9,22 @@
*
*/
#include
<math.h>
#include
<stdbool.h>
#include
<stdint.h>
#include
<stdio.h>
#include
<stdlib.h>
#include
<string.h>
bool
is_latin_square_normalized
(
int32_t
latin_square
[
4
][
4
])
{
for
(
int32_t
i
=
0
;
i
<
4
;
i
+=
1
)
{
if
(
latin_square
[
0
][
i
]
!=
i
+
1
||
latin_square
[
i
][
0
]
!=
i
+
1
)
{
#define LATIN_SQUARE_SIZE 4
/**
* @brief Checks if the Latin square is normalized.
*
* @param latin_square
* @return bool
*/
bool
is_latin_square_normalized
(
int32_t
latin_square
[
LATIN_SQUARE_SIZE
][
LATIN_SQUARE_SIZE
])
{
for
(
int32_t
i
=
0
;
i
<
LATIN_SQUARE_SIZE
;
i
+=
1
)
{
if
(
latin_square
[
0
][
i
]
!=
i
+
1
||
latin_square
[
i
][
0
]
!=
i
+
1
)
{
return
false
;
}
}
...
...
@@ -27,10 +33,11 @@ bool is_latin_square_normalized(int32_t latin_square[4][4]) {
}
int
main
()
{
int32_t
latin_square
[
4
][
4
];
int32_t
latin_square
[
LATIN_SQUARE_SIZE
][
LATIN_SQUARE_SIZE
];
for
(
int32_t
i
=
0
;
i
<
4
;
i
+=
1
)
{
for
(
int32_t
j
=
0
;
j
<
4
;
j
+=
1
)
{
// Initialization of the Latin square from the input data.
for
(
int32_t
i
=
0
;
i
<
LATIN_SQUARE_SIZE
;
i
+=
1
)
{
for
(
int32_t
j
=
0
;
j
<
LATIN_SQUARE_SIZE
;
j
+=
1
)
{
int32_t
tmp
;
scanf
(
"%d"
,
&
tmp
);
latin_square
[
i
][
j
]
=
tmp
;
...
...
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