Program HOC24;
const fi='cau2.inp'
fo='cau2.out'
var dt,a,b,c: integer;
procedure ip;
begin
assign(f,fi);
reset(f);
read(f,a,b,c);
close(f);
end;
procedure out;
begin
assign(f,fo);
rewrite(f);
dt:=b*b-4*a*c;
if dt>0 then write(f,'Phuong trinh co 2 nghiem phan biet');
if dt<0 then write(f,'Phuong trinh vo nghiem');
if dt=0 then write(f,'Phuong trinh co 2 nghiem kep');
close(f);
end;
begin
ip;
out;
end.
*Cách khác:
const fi='cau2.inp'
fo='cau2.out'
var f1,f2:text;
a,b,c,delta:real;
begin
assign(f1,fi); reset(f1);
assign(f2,fo); rewrite(f2);
readln(f1,a,b,c);
delta:=sqr(b)-4*a*c;
if delta<0 then writeln(f2,'Phuong trinh vo nghiem');
if delta=0 then writeln(f2,'Phuong trinh co nghiem kep la: ',-b/2*a:4:2);
if delta>0 then
begin
writeln(f2,'Nghiem thu nhat la: ',(-b-sqrt(delta))/2*a:4:2);
writeln(f2,'Nghiem thu hai la: ',(-b+sqrt(delta))/2*a:4:2);
end;
close(f1);
close(f2);
end.