Logique
Boucles
Math
Texte
Listes
Données
Variables
Fonctions
Programmation
p5.js
Objets web
Propriétés
Formes
Tortue
Apparence
var canvas, d, b, a, c, ligne1, ligne2, s1, ligne3, rd, s2, ligne4, commande, nomParametre, valeur, x; /** * Décrire cette fonction… */ function coeurSolution(a, b, c, ligne1, ligne2, ligne3, ligne4) { nePasTesterFonctionsDeBase(); // 'a est le coefficient de x^2' // 'b est le coefficient de x' // 'c est le terme constant' // 'La ligne 1 affiche le discriminant' // 'La ligne2 affiche le nombre de solutions réelles' // 'Las lignes 3 et 4 affichent les solutions (avec formules)' d = Math.pow(b, 2) - 4 * a * c; if (!estNombre(d)) { fixeContenuPrudent("ligne1",ligne1,'<b>Attention :</b> les valeurs de <i>a</i>, <i>b</i> et <i>c</i> doivent être <i>des nombres</i>.'); return ; } if (a == 0) { fixeContenuPrudent("ligne1",ligne1,'<b>Attention :</b> la valeur de <i>a</i> doit être <i>non nulle</i>.'); return ; } fixeContenuPrudent("ligne1",ligne1,(codeMath((substitution('"discriminant" =b^2-4ac=(@2)^2-4(@1)(@3)~~@4',[a, b, c, d]))))); if (d < 0) { fixeContenuPrudent("ligne2",ligne2,(codeMath('text(Pas de solution)'))); } if (d == 0) { s1 = -b / (2 * a); fixeContenuPrudent("ligne2",ligne2,(codeMath('text(Une solution)'))); fixeContenuPrudent("ligne3",ligne3,(codeMath((substitution('Solution =frac(-b)(2a)=frac(-(@2))(2(@1))~~@3',[a, b, s1]))))); } if (d > 0) { rd = Math.sqrt(d); s1 = (-b + rd) / (2 * a); s2 = (-b - rd) / (2 * a); fixeContenuPrudent("ligne2",ligne2,(codeMath('text(Deux solutions)'))); fixeContenuPrudent("ligne3",ligne3,(codeMath((substitution('Solution1 =frac(-b+sqrt(b^2-4ac))(2a)=frac(-(@2)+sqrt((@2)^2-4(@1)(@3)))(2(@1))~~ @4',[a, b, c, s1]))))); fixeContenuPrudent("ligne4",ligne4,(codeMath((substitution('Solution2 =frac(-b-sqrt(b^2-4ac))(2a)=frac(-(@2)-sqrt((@2)^2-4(@1)(@3)))(2(@1))~~@4 ',[a, b, c, s2]))))); } }