Une faute dans cet algorithme ?
Réponses à toutes vos questions de la 2nde à la Terminale toutes séries
-
CorentinG7
- Membre Naturel
- Messages: 16
- Enregistré le: 25 Oct 2014, 16:24
-
par CorentinG7 » 01 Nov 2014, 15:37
bonjour je dois faire un algorithme sur algobox. Je viens de le faire mais quand ;)>0 ou quand ;)=0 l'algorithme ne fait pas ce que je lui dit de faire, il me met "algorithme terminé"
Merci de m'aider.
Voici 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 x0 EST_DU_TYPE NOMBRE
7 x1 EST_DU_TYPE NOMBRE
8 x2 EST_DU_TYPE NOMBRE
9 DEBUT_ALGORITHME
10 LIRE a
11 LIRE b
12 LIRE c
13 delta PREND_LA_VALEUR pow(b,2)-4*a*c
14 SI (a=0) ALORS
15 DEBUT_SI
16 AFFICHER "a doit être différent de 0"
17 FIN_SI
18 SI (delta<0) ALORS
19 DEBUT_SI
20 AFFICHER ";)="
21 AFFICHER delta
22 AFFICHER "<0"
23 AFFICHER "Pas de racines"
24 FIN_SI
25 SI (delta=0) ALORS
26 DEBUT_SI
27 x0 PREND_LA_VALEUR -b/2*a
28 AFFICHER ";)=0"
29 AFFICHER "x0= -b/2a"
30 AFFICHER "x0="
31 AFFICHER x0
32 FIN_SI
33 SI (delta>0) ALORS
34 DEBUT_SI
35 x1 PREND_LA_VALEUR -b-sqrt(delta)/2*a
36 x2 PREND_LA_VALEUR -b+sqrt(delta)/2*a
37 AFFICHER ";)="
38 AFFICHER delta
39 AFFICHER ">0"
40 AFFICHER "x1= (-b-;))/2a"
41 AFFICHER "x1="
42 AFFICHER x1
43 AFFICHER "x2= (-b+;))/2a"
44 AFFICHER x2
45 FIN_SI
46 FIN_ALGORITHME
PS : quand je met mode pas à pas il me dit quand il arrive à ;)>0 "la condition n'est pas vérifiée"
-
CorentinG7
- Membre Naturel
- Messages: 16
- Enregistré le: 25 Oct 2014, 16:24
-
par CorentinG7 » 01 Nov 2014, 16:05
quelqu'un pour m'aider ?
-
WillyCagnes
- Membre Transcendant
- Messages: 3754
- Enregistré le: 21 Sep 2013, 19:58
-
par WillyCagnes » 01 Nov 2014, 18:57
bsr
mettre
13 delta PREND_LA_VALEUR b*b -4*a*c
mettre des ()
27 x0 PREND_LA_VALEUR -b/(2*a)
35 x1 PREND_LA_VALEUR (-b-sqrt(delta))/(2*a)
36 x2 PREND_LA_VALEUR (-b+sqrt(delta))/(2*a)
-
CorentinG7
- Membre Naturel
- Messages: 16
- Enregistré le: 25 Oct 2014, 16:24
-
par CorentinG7 » 01 Nov 2014, 19:00
WillyCagnes a écrit:bsr
mettre des ()
35 x1 PREND_LA_VALEUR (-b-sqrt(delta))/(2*a)
36 x2 PREND_LA_VALEUR (-b+sqrt(delta))/(2*a)
Bsr
Je viens d'essayer de mettre des () mais toujours pareil il me met condition non verifiée pour delta >0 et delta =0
Bizarre non ?
-
WillyCagnes
- Membre Transcendant
- Messages: 3754
- Enregistré le: 21 Sep 2013, 19:58
-
par WillyCagnes » 01 Nov 2014, 19:02
mettre
13 delta PREND_LA_VALEUR b*b -4*a*c
-
CorentinG7
- Membre Naturel
- Messages: 16
- Enregistré le: 25 Oct 2014, 16:24
-
par CorentinG7 » 01 Nov 2014, 19:31
WillyCagnes a écrit:mettre
13 delta PREND_LA_VALEUR b*b -4*a*c
pourquoi ?
-
paquito
- Membre Complexe
- Messages: 2168
- Enregistré le: 26 Fév 2014, 12:55
-
par paquito » 01 Nov 2014, 20:35
TU ne mets pas de parenthèses, donc ça fausse tous les calculs. Sinon ton algorithme est pas mal.
-
CorentinG7
- Membre Naturel
- Messages: 16
- Enregistré le: 25 Oct 2014, 16:24
-
par CorentinG7 » 01 Nov 2014, 20:37
paquito a écrit:TU ne mets pas de parenthèses, donc ça fausse tous les calculs. Sinon ton algorithme est pas mal.
Je viens de mettre les parenthese mais mon algorithme marche toujours pas pour delta >0 et delta =0 il ne fait que la premiere condition (delta <0)
-
WillyCagnes
- Membre Transcendant
- Messages: 3754
- Enregistré le: 21 Sep 2013, 19:58
-
par WillyCagnes » 02 Nov 2014, 11:01
bjr
essaie de modifier ton prog comme ceci
te laisse numeroter les lignes
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 x0 EST_DU_TYPE NOMBRE
7 x1 EST_DU_TYPE NOMBRE
8 x2 EST_DU_TYPE NOMBRE
9 DEBUT_ALGORITHME
10 LIRE a
11 LIRE b
12 LIRE c
13 delta PREND_LA_VALEUR pow(b,2)-4*a*c
33 SI (delta>0) ALORS
34 DEBUT_SI
35 x1 PREND_LA_VALEUR (-b-sqrt(delta))/(2*a)
36 x2 PREND_LA_VALEUR( -b+sqrt(delta))/(2*a)
37 AFFICHER ";)="
38 AFFICHER delta
39 AFFICHER ">0"
40 AFFICHER "x1= (-b-;))/2a"
41 AFFICHER "x1="
42 AFFICHER x1
43 AFFICHER "x2= (-b+;))/2a"
44 AFFICHER x2
45 FIN_SI
14 SI (a=0) ALORS
15 DEBUT_SI
16 AFFICHER "a doit être différent de 0"
17 FIN_SI
18 SI (delta<0) ALORS
19 DEBUT_SI
20 AFFICHER ";)="
21 AFFICHER delta
22 AFFICHER "<0"
23 AFFICHER "Pas de racines"
24 FIN_SI
25 SI (delta=0) ALORS
26 DEBUT_SI
27 x0 PREND_LA_VALEUR -b/2*a
28 AFFICHER ";)=0"
29 AFFICHER "x0= -b/2a"
30 AFFICHER "x0="
31 AFFICHER x0
32 FIN_SI
46 FIN_ALGORITHME
attention si a=0 alors x=-c/b
-
CorentinG7
- Membre Naturel
- Messages: 16
- Enregistré le: 25 Oct 2014, 16:24
-
par CorentinG7 » 02 Nov 2014, 12:06
WillyCagnes a écrit:bjr
essaie de modifier ton prog comme ceci
te laisse numeroter les lignes
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 x0 EST_DU_TYPE NOMBRE
7 x1 EST_DU_TYPE NOMBRE
8 x2 EST_DU_TYPE NOMBRE
9 DEBUT_ALGORITHME
10 LIRE a
11 LIRE b
12 LIRE c
13 delta PREND_LA_VALEUR pow(b,2)-4*a*c
33 SI (delta>0) ALORS
34 DEBUT_SI
35 x1 PREND_LA_VALEUR (-b-sqrt(delta))/(2*a)
36 x2 PREND_LA_VALEUR( -b+sqrt(delta))/(2*a)
37 AFFICHER ";)="
38 AFFICHER delta
39 AFFICHER ">0"
40 AFFICHER "x1= (-b-;))/2a"
41 AFFICHER "x1="
42 AFFICHER x1
43 AFFICHER "x2= (-b+;))/2a"
44 AFFICHER x2
45 FIN_SI
14 SI (a=0) ALORS
15 DEBUT_SI
16 AFFICHER "a doit être différent de 0"
17 FIN_SI
18 SI (delta<0) ALORS
19 DEBUT_SI
20 AFFICHER ";)="
21 AFFICHER delta
22 AFFICHER "<0"
23 AFFICHER "Pas de racines"
24 FIN_SI
25 SI (delta=0) ALORS
26 DEBUT_SI
27 x0 PREND_LA_VALEUR -b/2*a
28 AFFICHER ";)=0"
29 AFFICHER "x0= -b/2a"
30 AFFICHER "x0="
31 AFFICHER x0
32 FIN_SI
46 FIN_ALGORITHME
attention si a=0 alors x=-c/b
Merci je vais essayer
-
paquito
- Membre Complexe
- Messages: 2168
- Enregistré le: 26 Fév 2014, 12:55
-
par paquito » 02 Nov 2014, 12:44
Je t'envoie un algorithme basique, mais qui fonctionne bien:
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 DEBUT_ALGORITHME
7 LIRE a
8 SI (a==0) ALORS
9 DEBUT_SI
10 AFFICHER "a doit être différent d e 0!"
11 FIN_SI
12 LIRE b
13 LIRE c
14 Delta PREND_LA_VALEUR b*b-4*a*c
15 AFFICHER Delta
16 SI (Delta>0) ALORS
17 DEBUT_SI
18 AFFICHER " x1= "
19 AFFICHERCALCUL (-b-sqrt(Delta))/(2*a)
20 AFFICHER " x2= "
21 AFFICHERCALCUL (-b+sqrt(Delta))/(2*a)
22 FIN_SI
23 SI (Delta==0) ALORS
24 DEBUT_SI
25 AFFICHER " solution unique: x0= "
26 AFFICHERCALCUL -b/(2*a)
27 FIN_SI
28 SI (Delta<0) ALORS
29 DEBUT_SI
30 AFFICHER " Pas de solutions "
31 FIN_SI
32
33 FIN_ALGORITHME
Utilisateurs parcourant ce forum : Aucun utilisateur enregistré et 101 invités