program gpt_tp ;
uses crt ;
var a,b,c : integer ;
x,x1,x2,D : real ;
begin
clrscr;
writeln(' nhap vao he so cua phuong trinh ');
write('a = '); readln(a);
write('b = '); readln(b);
write('c = '); readln(c);
if a=0 then
if b = 0 then
begin
if c=0 then
writeln(' phuong trinh co vo so nghiem ')
else
writeln(' phuong trinh vo nghiem ');
end
else
begin
if c=0 then
writeln(' phuong trinh co nghiem x = 0')
else
x := -c/b ;
if (-c/b)>0 then
begin
writeln('nghiem thu nhat x = ', sqrt(-c/b):9:3);
writeln('nghiem thu hai x = ',-sqrt(-c/b):9:3);
end;
if (-c/b)<0 then
writeln('phuong trinh vo nghiem ');
end
else
begin
D := b*b - 4*a*c ;
if D<0 then
writeln('phuong trinh vo nghiem');
if D=0 then
begin
x:=(-b/2*a);
if (-b/2*a)>0 then
begin
writeln(' nghiem thu nhat x = ', sqrt(x):9:3);
writeln(' nghiem thu hai x = ',-sqrt(x):9:3);
end;
if (-b/2*a)<0 then
writeln(' phuong trinh vo nghiem ');
end;
if D>0 then
begin
x1 := (-b - sqrt(D))/2*a ;
x2 := (-b + sqrt(D))/2*a ;
if ( x1>0 ) and ( x2>0 ) then
begin
writeln(' nghiem thu nhat x = ', sqrt(x1):9:3);
writeln(' nghiem thu hai x = ',-sqrt(x1):9:3);
writeln(' nghiem thu ba x = ', sqrt(x2):9:3);
writeln(' nghiem thu tu x = ',-sqrt(x1):9:3);
end;
if (x1<0) and (x2<0 ) then
writeln('phuong trinh vo nghiem ');
if (x1>0) and (x2<0 ) then
begin
writeln(' nghiem thu nhat x = ', sqrt(x1):9:3);
writeln(' nghiem thu hai x = ',-sqrt(x1):9:3);
end;
if (x1<0) and (x2>0) then
begin
writeln(' nghiem thu nhat x = ', sqrt(x2):9:3);
writeln(' nghiem thu hai x = ',-sqrt(x2):9:3);
end;
end;
end;
readln;
end.