2026-10-14 11:02:36 +02:00
|
|
|
|
# Compte rendu – TD Complexité cyclomatique (R5.A.04)
|
|
|
|
|
|
|
2026-10-14 12:30:09 +02:00
|
|
|
|
Formules utilisées :
|
|
|
|
|
|
- avec le graphe : **M = E − N + 2P** (E arêtes, N sommets, P = 1)
|
|
|
|
|
|
- en comptant : **M = décisions + 1**
|
2026-10-14 11:02:36 +02:00
|
|
|
|
|
2026-10-14 12:30:09 +02:00
|
|
|
|
Classement selon la grille du cours : 1–10 simple, 11–20 modéré, 21–50 complexe, > 50 très risqué.
|
2026-10-14 11:02:36 +02:00
|
|
|
|
|
2026-10-14 12:30:09 +02:00
|
|
|
|
---
|
2026-10-14 11:02:36 +02:00
|
|
|
|
|
2026-10-14 12:30:09 +02:00
|
|
|
|
# Partie C – `exercices.c`
|
2026-10-14 11:02:36 +02:00
|
|
|
|
|
2026-10-14 12:30:09 +02:00
|
|
|
|
## __C1__ – `carre`
|
|
|
|
|
|
- complexite = 0 decisions + 1 = 1
|
|
|
|
|
|
|
|
|
|
|
|
> **Classement:**
|
|
|
|
|
|
|
|
|
|
|
|
Simple
|
|
|
|
|
|
|
|
|
|
|
|
## __C2__ – `moyenne`
|
2026-10-14 11:02:36 +02:00
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
2026-10-14 12:30:09 +02:00
|
|
|
|
- complexite = 9 aretes − 8 sommets + 2 = 3
|
|
|
|
|
|
- complexite = 2 decisions + 1 = 3
|
2026-10-14 11:02:36 +02:00
|
|
|
|
|
2026-10-14 12:30:09 +02:00
|
|
|
|
> **Cas particuliers:**
|
|
|
|
|
|
- ternaire `n > 0 ? ... : 0` : compte pour 1
|
|
|
|
|
|
|
|
|
|
|
|
> **Classement:**
|
|
|
|
|
|
|
|
|
|
|
|
Simple
|
|
|
|
|
|
|
|
|
|
|
|
## __C3__ – `est_bissextile`
|
|
|
|
|
|
- complexite = 2 decisions + 1 = 3
|
|
|
|
|
|
|
|
|
|
|
|
> **Cas particuliers:**
|
|
|
|
|
|
- `&&` et `||` sans `if` : 1 decision chacun (evaluation paresseuse)
|
|
|
|
|
|
|
|
|
|
|
|
> **Classement:**
|
|
|
|
|
|
|
|
|
|
|
|
Simple
|
|
|
|
|
|
|
|
|
|
|
|
## __C4__ – `nom_jour`
|
2026-10-14 11:42:40 +02:00
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
2026-10-14 12:30:09 +02:00
|
|
|
|
- complexite = 16 aretes − 10 sommets + 2 = 8
|
|
|
|
|
|
- complexite = 7 decisions + 1 = 8
|
2026-10-14 11:42:40 +02:00
|
|
|
|
|
2026-10-14 12:30:09 +02:00
|
|
|
|
> **Cas particuliers:**
|
|
|
|
|
|
- 7 `case` : 1 decision chacun
|
|
|
|
|
|
- `default` : ne compte pas
|
|
|
|
|
|
|
|
|
|
|
|
> **Classement:**
|
|
|
|
|
|
|
|
|
|
|
|
Simple
|
|
|
|
|
|
|
|
|
|
|
|
## __C5__ – `compter_mots`
|
|
|
|
|
|
- complexite = 7 decisions + 1 = 8
|
|
|
|
|
|
|
|
|
|
|
|
> **Cas particuliers:**
|
|
|
|
|
|
- `while` : 1
|
|
|
|
|
|
- `separateur = (... || ... || ... || ... || ...)` : 4 `||` sans `if`
|
|
|
|
|
|
- `if` + `else if` : 2
|
|
|
|
|
|
|
|
|
|
|
|
> **Classement:**
|
|
|
|
|
|
|
|
|
|
|
|
Simple
|
|
|
|
|
|
|
|
|
|
|
|
## __C6__ – `date_valide`
|
|
|
|
|
|
- complexite = 10 decisions + 1 = 11
|
|
|
|
|
|
|
|
|
|
|
|
> **Cas particuliers:**
|
|
|
|
|
|
- 1er `if` + 3 `||` : 4
|
|
|
|
|
|
- `if (mois == 2)` + `if (est_bissextile)` : 2
|
|
|
|
|
|
- `else if` + 3 `||` : 4
|
|
|
|
|
|
- l'appel a `est_bissextile` ne compte pas (M est calcule par fonction)
|
|
|
|
|
|
|
|
|
|
|
|
> **Classement:**
|
|
|
|
|
|
|
|
|
|
|
|
Modéré
|
|
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
|
|
# Partie Java – `Bibliotheque.java`
|
|
|
|
|
|
|
|
|
|
|
|
## __J1__ – `nombreDeLivres`
|
|
|
|
|
|
- complexite = 0 decisions + 1 = 1
|
|
|
|
|
|
|
|
|
|
|
|
> **Classement:**
|
|
|
|
|
|
|
|
|
|
|
|
Simple
|
|
|
|
|
|
|
|
|
|
|
|
## __J2__ – `estDisponible`
|
2026-10-14 11:02:36 +02:00
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
2026-10-14 12:30:09 +02:00
|
|
|
|
- complexite = 5 aretes − 4 sommets + 2 = 3
|
|
|
|
|
|
- complexite = 2 decisions + 1 = 3
|
2026-10-14 11:02:36 +02:00
|
|
|
|
|
2026-10-14 12:30:09 +02:00
|
|
|
|
> **Cas particuliers:**
|
|
|
|
|
|
- 2 `&&` sans `if` : 1 decision chacun
|
2026-10-14 11:02:36 +02:00
|
|
|
|
|
2026-10-14 12:30:09 +02:00
|
|
|
|
> **Classement:**
|
|
|
|
|
|
|
|
|
|
|
|
Simple
|
|
|
|
|
|
|
|
|
|
|
|
## __J3__ – `peutEmprunter`
|
|
|
|
|
|
- complexite = 8 decisions + 1 = 9
|
|
|
|
|
|
|
|
|
|
|
|
> **Cas particuliers:**
|
|
|
|
|
|
- 4 `if` + 2 `else if`
|
|
|
|
|
|
- ternaire `a.etudiant ? 8 : 5` : +1
|
|
|
|
|
|
- `l.reserve && !a.etudiant` : +1
|
|
|
|
|
|
|
|
|
|
|
|
> **Classement:**
|
|
|
|
|
|
|
|
|
|
|
|
Simple
|
|
|
|
|
|
|
|
|
|
|
|
## __J4__ – `calculerPenalite`
|
|
|
|
|
|
- complexite = 8 decisions + 1 = 9
|
|
|
|
|
|
|
|
|
|
|
|
> **Cas particuliers:**
|
|
|
|
|
|
- 4 `if` + 1 `else if` + 1 `for`
|
|
|
|
|
|
- `joursRetard <= 0 || nbLivres <= 0` : +1
|
|
|
|
|
|
- ternaire `penalite > 50 ? 50 : penalite` : +1
|
|
|
|
|
|
- `else` : ne compte pas
|
|
|
|
|
|
|
|
|
|
|
|
> **Classement:**
|
|
|
|
|
|
|
|
|
|
|
|
Simple
|
|
|
|
|
|
|
|
|
|
|
|
## __J5__ – `rechercher`
|
|
|
|
|
|
- complexite = 10 decisions + 1 = 11
|
|
|
|
|
|
|
|
|
|
|
|
> **Cas particuliers:**
|
|
|
|
|
|
- 1 `for` + 5 `if`
|
|
|
|
|
|
- `genre != null && ...` : +1
|
|
|
|
|
|
- `disponiblesSeulement && ...` : +1
|
|
|
|
|
|
- `motCle == null || ...` : +1
|
|
|
|
|
|
- `titre.contains(m) || auteur.contains(m)` : +1
|
|
|
|
|
|
- `continue` : ne compte pas
|
|
|
|
|
|
- l'appel a `estDisponible` ne compte pas
|
|
|
|
|
|
|
|
|
|
|
|
> **Classement:**
|
|
|
|
|
|
|
|
|
|
|
|
Modéré
|
|
|
|
|
|
|
|
|
|
|
|
## __J6__ – `importer`
|
2026-10-14 11:42:40 +02:00
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
2026-10-14 12:30:09 +02:00
|
|
|
|
- complexite = 21 aretes − 15 sommets + 2 = 8
|
|
|
|
|
|
- complexite = 7 decisions + 1 = 8
|
2026-10-14 11:42:40 +02:00
|
|
|
|
|
2026-10-14 12:30:09 +02:00
|
|
|
|
> **Cas particuliers:**
|
|
|
|
|
|
- 2 : `for`
|
|
|
|
|
|
- 3/4 : `if` + `||`
|
|
|
|
|
|
- 7 : `if`
|
|
|
|
|
|
- 10/11 : `if` + `&&`
|
|
|
|
|
|
- 13 : `catch`
|
|
|
|
|
|
- `continue` : ne compte pas
|
2026-10-14 11:42:40 +02:00
|
|
|
|
|
2026-10-14 12:30:09 +02:00
|
|
|
|
> **Classement:**
|
|
|
|
|
|
|
|
|
|
|
|
Simple
|
|
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
|
|
# Partie Python – `exercices.py`
|
|
|
|
|
|
|
|
|
|
|
|
## __P1__ – `celsius_vers_fahrenheit`
|
|
|
|
|
|
- complexite = 0 decisions + 1 = 1
|
|
|
|
|
|
|
|
|
|
|
|
> **Classement:**
|
|
|
|
|
|
|
|
|
|
|
|
Simple
|
|
|
|
|
|
|
|
|
|
|
|
## __P2__ – `signe`
|
2026-10-14 11:02:36 +02:00
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
2026-10-14 12:30:09 +02:00
|
|
|
|
- complexite = 7 aretes − 6 sommets + 2 = 3
|
|
|
|
|
|
- complexite = 2 decisions + 1 = 3
|
2026-10-14 11:02:36 +02:00
|
|
|
|
|
2026-10-14 12:30:09 +02:00
|
|
|
|
> **Cas particuliers:**
|
|
|
|
|
|
- `if` + `elif`
|
|
|
|
|
|
|
|
|
|
|
|
> **Classement:**
|
|
|
|
|
|
|
|
|
|
|
|
Simple
|
|
|
|
|
|
|
|
|
|
|
|
## __P3__ – `notes_valides`
|
2026-10-14 11:02:36 +02:00
|
|
|
|
|
|
|
|
|
|

|
|
|
|
|
|
|
2026-10-14 12:30:09 +02:00
|
|
|
|
- complexite = 6 aretes − 5 sommets + 2 = 3
|
|
|
|
|
|
- complexite = 2 decisions + 1 = 3
|
2026-10-14 11:02:36 +02:00
|
|
|
|
|
2026-10-14 12:30:09 +02:00
|
|
|
|
> **Cas particuliers:**
|
|
|
|
|
|
- comprehension de liste = 1 `for` + 1 `if`
|
|
|
|
|
|
- `0 <= n <= 20` : comparaison chainee comptee comme 1 seule condition
|
2026-10-14 11:02:36 +02:00
|
|
|
|
|
2026-10-14 12:30:09 +02:00
|
|
|
|
> **Classement:**
|
2026-10-14 11:02:36 +02:00
|
|
|
|
|
2026-10-14 12:30:09 +02:00
|
|
|
|
Simple
|
2026-10-14 11:42:40 +02:00
|
|
|
|
|
2026-10-14 12:30:09 +02:00
|
|
|
|
## __P4__ – `mention`
|
|
|
|
|
|
- complexite = 2 decisions + 1 = 3
|
2026-10-14 11:42:40 +02:00
|
|
|
|
|
2026-10-14 12:30:09 +02:00
|
|
|
|
> **Cas particuliers:**
|
|
|
|
|
|
- le dictionnaire remplace une cascade de `if/elif` (qui aurait donne M = 5)
|
2026-10-14 11:42:40 +02:00
|
|
|
|
|
2026-10-14 12:30:09 +02:00
|
|
|
|
> **Classement:**
|
2026-10-14 11:42:40 +02:00
|
|
|
|
|
2026-10-14 12:30:09 +02:00
|
|
|
|
Simple
|
2026-10-14 11:42:40 +02:00
|
|
|
|
|
2026-10-14 12:30:09 +02:00
|
|
|
|
## __P5__ – `analyser_mot_de_passe`
|
|
|
|
|
|
- complexite = 15 decisions + 1 = 16
|
2026-10-14 11:42:40 +02:00
|
|
|
|
|
2026-10-14 12:30:09 +02:00
|
|
|
|
> **Cas particuliers:**
|
|
|
|
|
|
- 2 `for`, 8 `if`, 2 `elif`
|
|
|
|
|
|
- `majuscule and minuscule` : +1
|
|
|
|
|
|
- `login and login.lower() in ...` : +1
|
|
|
|
|
|
- ternaire `"moyen" if ... else "faible"` : +1
|
|
|
|
|
|
- `else` et `break` : ne comptent pas
|
2026-10-14 11:42:40 +02:00
|
|
|
|
|
2026-10-14 12:30:09 +02:00
|
|
|
|
> **Classement:**
|
|
|
|
|
|
|
|
|
|
|
|
Modéré
|
|
|
|
|
|
|
|
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
|
|
# Récapitulatif
|
|
|
|
|
|
|
|
|
|
|
|
| Fonction | M | Classement |
|
2026-10-14 11:42:40 +02:00
|
|
|
|
|---|---|---|
|
2026-10-14 12:30:09 +02:00
|
|
|
|
| C1 `carre` | 1 | Simple |
|
|
|
|
|
|
| C2 `moyenne` | 3 | Simple |
|
|
|
|
|
|
| C3 `est_bissextile` | 3 | Simple |
|
|
|
|
|
|
| C4 `nom_jour` | 8 | Simple |
|
|
|
|
|
|
| C5 `compter_mots` | 8 | Simple |
|
|
|
|
|
|
| C6 `date_valide` | 11 | Modéré |
|
|
|
|
|
|
| J1 `nombreDeLivres` | 1 | Simple |
|
|
|
|
|
|
| J2 `estDisponible` | 3 | Simple |
|
|
|
|
|
|
| J3 `peutEmprunter` | 9 | Simple |
|
|
|
|
|
|
| J4 `calculerPenalite` | 9 | Simple |
|
|
|
|
|
|
| J5 `rechercher` | 11 | Modéré |
|
|
|
|
|
|
| J6 `importer` | 8 | Simple |
|
|
|
|
|
|
| P1 `celsius_vers_fahrenheit` | 1 | Simple |
|
|
|
|
|
|
| P2 `signe` | 3 | Simple |
|
|
|
|
|
|
| P3 `notes_valides` | 3 | Simple |
|
|
|
|
|
|
| P4 `mention` | 3 | Simple |
|
|
|
|
|
|
| P5 `analyser_mot_de_passe` | 16 | Modéré |
|