Tester l'algorithme :
Graphique :
Code de l'algorithme :
1
VARIABLES
2
Somme EST_DU_TYPE NOMBRE
3
Produit EST_DU_TYPE NOMBRE
4
Nombre1 EST_DU_TYPE NOMBRE
5
Nombre2 EST_DU_TYPE NOMBRE
6
X EST_DU_TYPE NOMBRE
7
W EST_DU_TYPE NOMBRE
8
DEBUT_ALGORITHME
9
W PREND_LA_VALEUR 50
10
AFFICHER "Penser à 2 nombres entiers positifs."
11
PAUSE
12
AFFICHER "Maintenant que vous avez ces 2 nombres en tête je vais essayer de les deviner."
13
AFFICHER "Pour cela vous devez me donner leur somme."
14
LIRE Somme
15
AFFICHER "Maintenant il me faudrait leur produit."
16
LIRE Produit
17
AFFICHER "Merci. Maintenat je vais me concentrer"
18
POUR X ALLANT_DE 1 A 80000
19
DEBUT_POUR
20
W PREND_LA_VALEUR W*2
21
W PREND_LA_VALEUR W/2
22
SI (X==20000 OU X==40000 OU X==60000) ALORS
23
DEBUT_SI
24
AFFICHER "."
25
FIN_SI
26
FIN_POUR
27
AFFICHER " "
28
AFFICHER " "
29
Nombre1 PREND_LA_VALEUR (Somme+sqrt(pow(Somme,2)-4*Produit))/2
30
Nombre2 PREND_LA_VALEUR (Somme-sqrt(pow(Somme,2)-4*Produit))/2
31
AFFICHER "Vos 2 nombres sont "
32
AFFICHER Nombre1
33
AFFICHER " et "
34
AFFICHER Nombre2
35
FIN_ALGORITHME