Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cours
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
Model registry
Operate
Environments
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
Show more breadcrumbs
programmation_sequentielle
cours
Commits
ea6626fd
Verified
Commit
ea6626fd
authored
1 month ago
by
orestis.malaspin
Browse files
Options
Downloads
Patches
Plain Diff
date
parent
20a194c7
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Pipeline
#37877
passed
1 month ago
Stage: test
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
exemples/alot_of_scanfs.c
+0
-103
0 additions, 103 deletions
exemples/alot_of_scanfs.c
exemples/sum_n.c
+0
-22
0 additions, 22 deletions
exemples/sum_n.c
slides/les_exos_avec_le_dojo.md
+1
-1
1 addition, 1 deletion
slides/les_exos_avec_le_dojo.md
with
1 addition
and
126 deletions
exemples/alot_of_scanfs.c
deleted
100644 → 0
+
0
−
103
View file @
20a194c7
#include
<stdio.h>
#include
<stdlib.h>
#include
<string.h>
// Ce programme prend en argument deux
// entiers se trouvant chacun
// sur une nouvelle ligne et affiche
// la somme des deux entiers en argument
// sur une nouvelle ligne.
// Ex:
// 12
// 19
//
// 31
void
sum_two
()
{
int
a
,
b
;
scanf
(
"%d %d"
,
&
a
,
&
b
);
printf
(
"
\n
%d
\n
"
,
a
+
b
);
}
// Ce programme prend en argument 12 nombres à
// virgule flottante se trouvant chacun
// sur une nouvelle ligne. Multiplie chaque
// nombre par deux et affiche leur somme
// sur une nouvelle ligne suivi de CHF.
// Ex:
// 12.2
// 45.5
// 1.5
// 65.1
// 89.4
// 567.6
// 112.8
// 67.0
// 35.1
// 112.2
// 3.3
// 9.8
//
// 2243.000000 CHF
void
sum_array
()
{
float
sum
=
0
.
0
;
for
(
int
i
=
0
;
i
<
12
;
++
i
)
{
float
a
=
0
.
0
;
scanf
(
"%f"
,
&
a
);
a
*=
2
.
0
;
sum
+=
a
;
}
printf
(
"
\n
%f CHF
\n
"
,
sum
);
}
// Ce programme prend en argument 2 chaînes de
// caractères sur des lignes séparées (longueur
// max de 80), les sépare au milieu et retourne
// les 4 chaînes chacune sur une nouvelle ligne
// (si la longueur N est paire on sépare en 2
// chaînes de longueur N/2, sinon la première
// aura une longueur de N/2 et la seconde N/2+1).
// Ex:
// abcdefgh
// asdfghjkl
//
// abcd
// efgh
// asdf
// ghjkl
void
split_mid
()
{
char
str_one
[
2
][
41
],
str_two
[
2
][
41
];
for
(
int
j
=
0
;
j
<
2
;
++
j
)
{
char
str
[
81
];
scanf
(
"%s"
,
str
);
int
n
=
strlen
(
str
);
int
n1
=
n
/
2
;
int
n2
=
n
-
n1
;
for
(
int
i
=
0
;
i
<
n1
;
++
i
)
{
str_one
[
j
][
i
]
=
str
[
i
];
}
str_one
[
j
][
n1
]
=
'\0'
;
for
(
int
i
=
0
;
i
<
n2
;
++
i
)
{
str_two
[
j
][
i
]
=
str
[
n1
+
i
];
}
str_two
[
j
][
n2
]
=
'\0'
;
}
printf
(
"
\n
"
);
for
(
int
j
=
0
;
j
<
2
;
++
j
)
{
printf
(
"%s
\n
"
,
str_one
[
j
]);
printf
(
"%s
\n
"
,
str_two
[
j
]);
}
}
int
main
()
{
/* sum_two(); */
sum_array
();
/* split_mid(); */
}
This diff is collapsed.
Click to expand it.
exemples/sum_n.c
deleted
100644 → 0
+
0
−
22
View file @
20a194c7
#include
<stdio.h>
#include
<stdlib.h>
int
main
()
{
printf
(
"Enter n: "
);
// affichage chaine de caractères
int
n
=
0
;
// déclaration et initialisation de n
scanf
(
"%d"
,
&
n
);
// entrée au clavier
int
sum
=
0
;
// déclaration et initialisation de sum
for
(
int
i
=
0
;
i
<=
n
;
++
i
)
{
// boucle for
sum
+=
i
;
}
printf
(
"The sum of the %d first integers is: %d
\n
"
,
n
,
sum
);
// affichage de n et sum
printf
(
"The analytical formula is %d * (%d + 1) / 2 = %d.
\n
"
,
n
,
n
,
n
*
(
n
+
1
)
/
2
);
// on peut mettre n'importe quelle expression
if
(
sum
!=
n
*
(
n
+
1
)
/
2
)
{
// branchement conditionnel
printf
(
"Error: The answer we computed is wrong.
\n
"
);
return
EXIT_FAILURE
;
// code d'erreur
}
return
EXIT_SUCCESS
;
// code de réussite
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
slides/les_exos_avec_le_dojo.md
+
1
−
1
View file @
ea6626fd
---
title
:
"
Dojo"
date
:
"
202
4
-02-21"
date
:
"
202
5
-02-21"
---
# Le Dojo
...
...
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