4

Click here to load reader

C++ Par La Pratique (PPUR)

  • Upload
    whiterg

  • View
    345

  • Download
    1

Embed Size (px)

Citation preview

Page 1: C++ Par La Pratique (PPUR)

C++ par la pratique

Recueil d'exercices corrigés et aide-mémoire

J.-C. Chappelier & F. Seydoux

ErrataRécupérer l'ensemble des codes sources des corrigés (compressés au format zip, 80 Ko).Corrigés :

Variables, opérateurs et expressionsExercice 1 : quel âge avez-vous ? (variables)

Solution 1 : voir/view avoir/downloadSolution 2 : voir/view avoir/downloadSolution 3 : voir/view avoir/download

Exercice 2 : quelques calculs (variables et expressions)voir/view avoir/download

1.

Structures de contrôleExercice 3 : tables de multiplication (itération for)

voir/view avoir/downloadExercice 4 : intervalles (expressions conditionnelles)

Solution 1 : voir/view avoir/downloadSolution 2 : voir/view avoir/download

Exercice 5 : expressions arithmétiques (expressions, branchements conditionnels)voir/view avoir/download

Exercice 6 : rebonds de balles (itération for)voir/view avoir/download

Exercice 7 : rebonds de balles revisités (boucles do...while)voir/view avoir/download

Exercice 8 : une histoire de prêt (boucles)voir/view avoir/download

Exercice 9 : nombres premiers (structures de contrôle)voir/view avoir/download

Exercice 10 : équations du 3e degré (expressions, structures de contrôles)voir/view avoir/download

2.

FonctionsExercice 11 : portée

voir/view avoir/downloadExercice 12 : demander un nombre (prototypes)

Solution 1 : voir/view avoir/downloadSolution 2 : voir/view avoir/downloadSolution 3 : voir/view avoir/download

Exercice 13 : échanges (passage des paramètres, surcharge)Solution 1 : voir/view avoir/downloadSolution 2 : voir/view avoir/download

Exercice 14 : la fonction cosinus (définition et appel de fonction)voir/view avoir/download

Exercice 15 : calcul approché d'une intégrale (fonctions)voir/view avoir/download

3.

Types avancésExercice 16 : générateur automatique de lettres (fonctions, chaînes de caractères)

4.

C++ par la pratique (PPUR) http://icwww.epfl.ch/~chappeli/cppplp/

1 sur 4 15/09/2013 21:41

Page 2: C++ Par La Pratique (PPUR)

Solution 1 : voir/view avoir/downloadSolution 2 : voir/view avoir/download

Exercice 17 : produit scalaire (tableaux de taille fixe)Solution 1 : voir/view avoir/downloadSolution 2 : voir/view avoir/download

Exercice 18 : échauffement avec les tableaux dynamiquesExercice 19 : segmentation en mots (string)

voir/view avoir/downloadExercice 20 : multiplication de matrices (tableaux dynamiques)

voir/view avoir/downloadExercice 21 : placement sans recouvrement (tableaux)

voir/view avoir/downloadExercice 22 : nombres complexes (structures)

voir/view avoir/downloadExercice 23 : sélection (pointeurs)

voir/view avoir/downloadExercice 24 : QCM (structures + vector)

voir/view avoir/downloadExercice 25 : nombres complexes revisités (structures)

voir/view avoir/downloadExercice 26 : multiplications de matrices revisitées (pointeur)

Solution 1 : voir/view avoir/downloadSolution 2 : voir/view avoir/download

Exercice 27 : intégrales revisitées (tableaux, pointeurs)voir/view avoir/download

FlotsExercice 28 : écriture dans un fichier (ofstream)

voir/view avoir/downloadExercice 29 : lecture depuis un fichier (ifstream + manipulateurs)

voir/view avoir/downloadExercice 30 : statistiques sur un fichier (fichiers, tableaux)

voir/view avoir/downloadExercice 31 : QCM revisités (fichiers, structures)

Solution : voir/view avoir/downloadExemple de fichier : avoir/download

5.

Fonctions récursivesExercice 32 : factorielle (fonctions récursives)

voir/view avoir/downloadExercice 33 : nombres de Fibonacci (fonctions récursives)

voir/view avoir/downloadExercice 34 : recherche dichotomique (fonctions récursives)

voir/view avoir/downloadExercice 35 : tours de Hanoï (fonctions récursives)

voir/view avoir/downloadExercice 36 : mythiques labyrinthes (fonctions récursives)

Solution 1 : voir/view avoir/downloadSolution 2 : voir/view avoir/download

6.

Exercices générauxExercice 37 : tri bulles

voir/view avoir/downloadExercice 38 : algorithme d'Euclide

voir/view avoir/downloadExercice 39 : piles et parenthèses

voir/view avoir/download

7.

C++ par la pratique (PPUR) http://icwww.epfl.ch/~chappeli/cppplp/

2 sur 4 15/09/2013 21:41

Page 3: C++ Par La Pratique (PPUR)

Exercice 40 : arithmétique rationnellevoir/view avoir/download

Exercice 41 : piles et notation polonaise inversevoir/view avoir/download

Exercice 42 : recherche approchée de racinevoir/view avoir/download

Exercice 43 : culture de massevoir/view avoir/download

Exercice 44 : tri de Shellvoir/view avoir/download

Exercice 45 : jeu du penduvoir/view avoir/download

Introduction à la POOExercice 46 : petits ronds (objets/classes)

voir/view avoir/downloadExercice 47 : coordonnées tridimensionnelles (objets/classes)

voir/view avoir/downloadExercice 48 : un petit tour de magie (objets/classes)

voir/view avoir/download

8.

Constructeurs et destructeursExercice 49 : apéritif (constructeurs/destructeurs)

voir/view avoir/downloadExercice 50 : un peu de douceur dans ce monde de brutes(constructeurs/destructeurs)

voir/view avoir/downloadExercice 51 : balles rebondissantes, le retour (constructeurs/destructeurs)

voir/view avoir/download

9.

Surcharge d'opérateursExercice 52 : nombres complexes (surcharge d'opérateurs)

voir/view avoir/downloadExercice 53 : nombres complexes encore (pointeurs, constructeurs)

voir/view avoir/downloadExercice 54 : encore un peu plus de polynômes (surcharge d'opérateurs)

voir/view avoir/download

10.

HéritageExercice 55 : que de véhicules ! (héritage)

voir/view avoir/downloadExercice 56 : vecteurs tridimensionnels (héritage)

voir/view avoir/downloadExercice 57 : vecteurs unitaires (héritage)

voir/view avoir/downloadExercice 58 : un peu d'algèbre élémentaire (héritage)

voir/view avoir/downloadExercice 59 : un peu plus d'algèbre élémentaire (héritage)

voir/view avoir/download

11.

PolymorphismeExercice 60 : formes polymorphiques (polymorphisme)

voir/view avoir/downloadExercice 61 : encore des figures géométriques (collection hétérogène)

voir/view avoir/downloadExercice 62 : puissance 4 (polymorphisme)

voir/view avoir/download

12.

Héritage multipleExercice 63 : animaux en peluche (héritage multiple)

13.

C++ par la pratique (PPUR) http://icwww.epfl.ch/~chappeli/cppplp/

3 sur 4 15/09/2013 21:41

Page 4: C++ Par La Pratique (PPUR)

voir/view avoir/downloadExercice 64 : employés (héritage multiple, collection hétérogène)

voir/view avoir/downloadExercice 65 : jeu de cartes (héritage multiple)

voir/view avoir/downloadTemplates et STL

Exercice 66 : ensembles et itérateurs (STL)voir/view avoir/download

Exercice 67 : tris revisités (template, STL)Solution 1 : voir/view avoir/downloadSolution 2 : voir/view avoir/download

14.

ExceptionsExercice 68 : le retour des rationnels (exceptions)

voir/view avoir/downloadExercice 69 : compression RLE (exceptions)

voir/view avoir/download

15.

Exercices générauxExercice 70 : algèbre matricielle

voir/view avoir/downloadExercice 71 : fichiers et programmes

voir/view avoir/downloadExercice 72 : bibliothèque 1

voir/view avoir/downloadExercice 73 : échecs

voir/view avoir/downloadExercice 74 : bibliothèque 2

voir/view avoir/download

16.

Dernière mise à jour le 15 décembre 2009Last modified: Tue Dec 15, 2009 ($Revision: 1.11 $).

C++ par la pratique (PPUR) http://icwww.epfl.ch/~chappeli/cppplp/

4 sur 4 15/09/2013 21:41