La programmation(1).pdf

(3649 KB) Pobierz
LA PROGRAMMATION POUR...
les élèves ingénieurs
. . . ou les collégiens
débutants
. . . ou confirmés
Cours de l’École des ponts - 2007/2008
Renaud Keriven
CERTIS
- ENPC
keriven@certis.enpc.fr
Version électronique
et programmes téléchargeables sur
http://certis.enpc.fr/~keriven/Info/
Recommandation :
"Ne traitez pas vos ordinateurs comme des êtres vivants !
... Ils n’aiment pas ça !"
A méditer :
"Cet ordinateur ne fait pas du tout ce que je veux !"
"Exact... Il fait ce que tu lui demandes de faire !"
TABLE DES MATIÈRES
TABLE DES MATIÈRES
Table des matières
1 Préambule
1.1 Pourquoi savoir programmer ?
. .
1.2 Comment apprendre ?
. . . . . .
1.2.1 Choix du langage
. . . . .
1.2.2 Choix de l’environnement
1.2.3 Principes et conseils
. . .
7
9
10
10
10
11
13
15
15
17
18
20
21
22
22
23
23
25
25
25
29
31
32
34
37
38
39
42
43
44
44
45
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
2 Bonjour, Monde !
2.1 L’ordinateur
. . . . . . . . . . . . .
2.1.1 Le micro-processeur
. . . . .
2.1.2 La mémoire
. . . . . . . . .
2.1.3 Autres Composants
. . . . .
2.2 Système d’exploitation
. . . . . . .
2.3 La Compilation
. . . . . . . . . . .
2.4 L’environnement de programmation
2.4.1 Noms de fichiers
. . . . . . .
2.4.2 Debuggeur
. . . . . . . . . .
2.4.3 TP
. . . . . . . . . . . . . .
3 Premiers programmes
3.1 Tout dans le
main()
!
. . . . . . . . .
3.1.1 Variables
. . . . . . . . . . . .
3.1.2 Tests
. . . . . . . . . . . . . .
3.1.3 Boucles
. . . . . . . . . . . .
3.1.4 Récréations
. . . . . . . . . .
3.2 Fonctions
. . . . . . . . . . . . . . .
3.2.1 Retour
. . . . . . . . . . . . .
3.2.2 Paramètres
. . . . . . . . . .
3.2.3 Passage par référence
. . . . .
3.2.4 Portée, Déclaration, Définition
3.2.5 Variables locales et globales
.
3.2.6 Surcharge
. . . . . . . . . . .
3.3 TP
. . . . . . . . . . . . . . . . . . .
3.4 Fiche de référence
. . . . . . . . . . .
4 Les
4.1
4.2
4.3
tableaux
47
Premiers tableaux
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 47
Initialisation
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
Spécificités des tableaux
. . . . . . . . . . . . . . . . . . . . . . . . . . . . 50
Zgłoś jeśli naruszono regulamin