Var a,b,c,d:real; procedure p(a,b,c:real; var d:real); begin d:=b*b-4*a*c; end; begin readln(a,b,c); p(a,b,c,d); if d<0 then writeln('Корней нет') else if d=0 then writeln('x = ',-b/(2*a):3:1) else writeln('x1 = ',(-b+d)/(2*a):3:1,' x2 = ',(-b-d)/(2*a):3:1); end.
Answers & Comments
Verified answer
Var a,b,c,d:real;procedure p(a,b,c:real; var d:real);
begin
d:=b*b-4*a*c;
end;
begin
readln(a,b,c);
p(a,b,c,d);
if d<0 then writeln('Корней нет')
else if d=0 then writeln('x = ',-b/(2*a):3:1)
else writeln('x1 = ',(-b+d)/(2*a):3:1,' x2 = ',(-b-d)/(2*a):3:1);
end.
Пример:
2 3 1
x1 = -0.5 x2 = -1.0