Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cours_prog
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
Show more breadcrumbs
yassin.elhakoun
cours_prog
Commits
5afd7f5b
Commit
5afd7f5b
authored
5 years ago
by
orestis.malaspin
Browse files
Options
Downloads
Patches
Plain Diff
updated with metropolis
parent
ad481ca9
No related branches found
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
Makefile
+18
-10
18 additions, 10 deletions
Makefile
base_1.md
+2
-3
2 additions, 3 deletions
base_1.md
base_2.md
+42
-39
42 additions, 39 deletions
base_2.md
metadata.yaml
+7
-0
7 additions, 0 deletions
metadata.yaml
with
69 additions
and
52 deletions
Makefile
+
18
−
10
View file @
5afd7f5b
OPTIONS
=
--filter
=
pandoc-numbering
OPTIONS
+=
--filter
=
pandoc-crossref
DATADIR
=
./
FILTERDIR
=
$(
DATADIR
)
/filters
RESOURCEDIR
=
$(
DATADIR
)
/resources
PDFOPTIONS
=
--highlight-style
my_highlight.theme
PDFOPTIONS
=
-t
beamer
PDFOPTIONS
+=
--highlight-style
my_highlight.theme
PDFOPTIONS
+=
--pdf-engine
pdflatex
PDFOPTIONS
+=
--number-sections
PDFOPTIONS
+=
--template
=
./default.latex
PDFOPTIONS
+=
-V
theme:metropolis
PDFOPTIONS
+=
-V
themeoptions:numbering
=
none
-V
themeoptions:progressbar
=
foot
PDFOPTIONS
+=
-V
fontsize
=
smaller
# PDFOPTIONS += --lua-filter=${FILTERDIR}/tex.lua
# PDFOPTIONS += --include-in-header=${RESOURCEDIR}/definitions.tex
# PDFOPTIONS += --include-in-header=${RESOURCEDIR}/beamer.tex
PDFOPTIONS
+=
$(
OPTIONS
)
HTMLOPTIONS
+=
-t
html5
HTMLOPTIONS
+=
-c
css/tufte-css/tufte.css
...
...
@@ -12,14 +20,14 @@ HTMLOPTIONS += --self-contained
all
:
base_2.pdf base_1.pdf intro.pdf index.html
intro.pdf
:
intro.md *.theme
pandoc
-t
beamer
-o
$@
$
<
intro.pdf
:
intro.md
metadata.yaml
*.theme
pandoc
$(
PDFOPTIONS
)
-o
$@
$
^
base_1.pdf
:
base_1.md *.theme
pandoc
-t
beamer
-o
$@
$
<
base_1.pdf
:
base_1.md
metadata.yaml
*.theme
pandoc
$(
PDFOPTIONS
)
-o
$@
$
^
base_2.pdf
:
base_2.md *.theme figs/memory.svg
pandoc
-t
beamer
-o
$@
$
<
base_2.pdf
:
base_2.md
metadata.yaml
*.theme figs/memory.svg
pandoc
$(
PDFOPTIONS
)
-o
$@
$
^
index.html
:
index.md
pandoc
-s
$(
OPTIONS
)
$(
HTMLOPTIONS
)
-o
$@
$<
...
...
This diff is collapsed.
Click to expand it.
base_1.md
+
2
−
3
View file @
5afd7f5b
%
Programmation séquentielle en C
%
Base I -
Inspirés des slides de F. Glück
%
Base I
% Inspirés des slides de F. Glück
% 18 septembre 2019
# Historique (1/2)
...
...
@@ -66,7 +66,6 @@ int main() {
1. `-std=c11` utilisation de C11.
2. `-Wall et -Wextra` activation des warnings.
3. `-fsanitize=…` contrôles d’erreurs extensifs à l’exécution (au prix d’un coût en performance).
Sur Ubuntu 14.04 `-fsanitize=leak` et `-fsanitize=undefined` ne sont pas supportés (`cat /etc/lsb-release` indique la version).
4. `-g` symboles de débogages sont gardés.
5. `-o` défini le fichier exécutable à produire en sortie.
<!-- 6. `-O1`, `-O2`, `-O3`: activation de divers degrés d'optimisation -->
...
...
This diff is collapsed.
Click to expand it.
base_2.md
+
42
−
39
View file @
5afd7f5b
...
...
@@ -6,23 +6,22 @@
## La mémoire
-
La mémoire est un ensemble de bits.
-
Elle est accessible via des adresses.
*
La mémoire est:
-
... un ensemble de bits,
-
... accessible via des adresses,
+------+----------+----------+------+----------+------+------+
| bits | 00110101 | 10010000 | .... | 00110011 | .... | .... |
+======+==========+==========+======+==========+======+======+
| addr | 2000 | 2001 | .... | 4000 | .... | .... |
+------+----------+----------+------+----------+------+------+
+------+----------+----------+------+----------+------+------+
| bits | 00110101 | 10010000 | .... | 00110011 | .... | .... |
+======+==========+==========+======+==========+======+======+
| addr | 2000 | 2001 | .... | 4000 | .... | .... |
+------+----------+----------+------+----------+------+------+
-
Elle est gérée par le système d'exploitation...
-
et fournie à chaque programme pendant son exécution.
-
Elle est séparée en deux parties:
**la pile**
et
**le tas**
.
- ... gérée par le système d'exploitation.
- ... séparée en deux parties: **la pile** et **le tas**.
## Une variable
-
Une variable est un identifiant pour une valeur.
-
Une variable,
`type a = valeur`
{.C}, possède:
*
Une variable,
`type a = valeur`
{.C}, possède:
-
un type (
`char`
{.C},
`int`
{.C}, ...),
-
un contenu (une séquence de bits qui encode
`valeur`
{.C}),
-
une adresse mémoire (accessible via
`&a`
{.C}),
...
...
@@ -111,20 +110,20 @@
# Les fonctions (2/N)
-
Exemple
:
##
Exemple
```C
int max(int a, int b) {
if (a > b) {
return a;
} else {
return b;
}
```
C
int max(int a, int b) {
if (a > b) {
return a;
} else {
return b;
}
}
int main() {
int c = max(4, 5);
}
int main() {
int c = max(4, 5);
}
```
# Les fonctions (3/N)
...
...
@@ -193,22 +192,26 @@
- Pour modifier un variable, il faut passer son **adresse mémoire**.
- L'adresse d'une variable, `x`{.C}, est accédé par `&x`{.C}.
- Un **pointeur** vers une variable entière a le type, `int *x`{.C}.
-
La sytaxe
`*x`
{.C} sert à
**déréférencer**
le pointeur.
- La sytaxe `*x`{.C} sert à **déréférencer** le pointeur
(à accéder à la mémoire pointée)
.
```C
void set_to_two(int *a) {
// a contient une copie de l'adresse de la
// variable passée en argument
# Les fonctions (7/N)
*a = 2; // on accède à la valeur pointée par a,
// et on lui assigne 2
} // le pointeur est détruit, pas la valeur pointée
int main() {
int x = -1;
set_to_two(&x); // l'adresse de x est passée
// x vaudra 2 ici
}
```
## Exemple
```
C
void set_to_two(int
*
a) {
// a contient une copie de l'adresse de la
// variable passée en argument
*a = 2; // on accède à la valeur pointée par a,
// et on lui assigne 2
} // le pointeur est détruit, pas la valeur pointée
int main() {
int x = -1;
set_to_two(
&x);
// l'adresse de x est passée
// x vaudra 2 ici
}
```
<!-- TODO quiz;
```
C
...
...
@@ -375,9 +378,9 @@ do {
## Les tableaux comme argument
-
Un tableau
n'
est
rien d'autre que
le pointeur vers sa première case.
-
Un tableau est le pointeur vers sa première case.
-
Pas moyen de connaître sa taille:
`sizeof()`
{.C} inutile.
-
Quand on passe
un tableau en argument
à une fonction: toujours spécifier sa taille
.
-
Toujours spécifier la taille d'
un tableau
passé
en argument.
```C
void foo(int tab[]) { // sans taille...
...
...
This diff is collapsed.
Click to expand it.
metadata.yaml
0 → 100644
+
7
−
0
View file @
5afd7f5b
---
# used for lecture slides and homework sheets
subtitle
:
"
Programmation
séquentielle
en
C,
2019-2020"
author
:
"
Orestis
Malaspinas,
ITI,
HEPIA"
lang
:
fr-CH
...
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