1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86
| program CAPRJ001;
uses crt;
var A,B,C,DELTA,x1,x2:real;
R:char;
begin
repeat
clrscr;
writeln('Equation du second degre');
writeln('==========================');
writeln('Entrez une valeur de A');
readln(A);
writeln('Entrez une valeur de B');
readln(B);
writeln('Entrez une valeur de C');
readln(C);
writeln(A:8:3,'Xý+',B:8:3 ,'X+',C:8:3,'=0');
writeln('==========================');
if A=0
then
begin
if B=0
then
begin
if C=0
then
writeln('X= ensemble R')
else
writeln('Pas de solution')
end
else
begin
writeln('Equation du premier degre');
writeln('=========================');
writeln('X=',-C/B:8:3);
end
end
else
begin
DELTA:=sqr(B)-4*A*C;
if DELTA<0
then
begin
writeln('Racines complexes');
writeln('=================');
x1:=-B/(2*A);
x2:=sqrt(-DELTA/(2*A));
writeln('X1=',x1:8:3,'+',x2:8:3,'i');
writeln('X2=',x1:8:3,'-',x2:8:3,'i');
end;
if DELTA=0
then
begin
writeln('Racine double');
writeln('=============');
x1:=-B/(2*A);
writeln('X=',x1:8:3);
end;
if DELTA>0
then
begin
writeln('Racines reelles');
writeln('===============');
x1:=(-B+sqrt(DELTA))/(2*A);
x2:=(-B-sqrt(DELTA))/(2*A);
writeln('X1=',x1:8:3);
writeln('X2=',x2:8:3);
end;
end;
writeln('=========================');
writeln('Voulez vous recommencer ? <O/N>');
readln(R);
until (R='N') or (R='n');
end. |
Partager