AlgoBox : algobox-trinome

résolution d'une équation du second degré

Tester l'algorithme
Cliquer sur ce bouton pour exécuter l'algorithme : 

Résultats

Code de l'algorithme
1   VARIABLES
2     a EST_DU_TYPE NOMBRE
3     b EST_DU_TYPE NOMBRE
4     c EST_DU_TYPE NOMBRE
5     delta EST_DU_TYPE NOMBRE
6     x1 EST_DU_TYPE NOMBRE
7     x2 EST_DU_TYPE NOMBRE
8   DEBUT_ALGORITHME
9     LIRE a
10    LIRE b
11    LIRE c
12    delta PREND_LA_VALEUR pow(b,2)-4*a*c
13    SI (delta>0) ALORS
14      DEBUT_SI
15      x1 PREND_LA_VALEUR (-b+sqrt(delta))/2/a
16      x2 PREND_LA_VALEUR (-b-sqrt(delta))/2/a
17      AFFICHER "Le trinôme a deux racines :"
18      AFFICHER x1
19      AFFICHER " et "
20      AFFICHER x2
21      FIN_SI
22      SINON
23        DEBUT_SINON
24        SI (delta==0) ALORS
25          DEBUT_SI
26          x1 PREND_LA_VALEUR -b/2/a
27          AFFICHER "Le trinôme a une unique racine :"
28          AFFICHER x1
29          FIN_SI
30          SINON
31            DEBUT_SINON
32            AFFICHER "Le trinôme n'a pas de racine"
33            FIN_SINON
34        FIN_SINON
35  FIN_ALGORITHME