Advertisement
Guest User

Untitled

a guest
Jan 24th, 2020
1,002
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. Program Roots;
  2. var a, b, c, d, x1, x2: real;
  3. begin
  4. WriteLn('Введите коэффициенты квадратного уравнения:');
  5. a:=0;
  6. while a=0 do begin Write('a='); ReadLn(a); end;
  7. Write('b='); ReadLn(b);
  8. Write('c='); ReadLn(c);
  9. if a=0
  10. then
  11. if b=0
  12. then
  13. if c=0
  14. then WriteLn('Любое x - решение')
  15. else WriteLn('Нет решений')
  16. else
  17. begin
  18. x1:=-c/b;
  19. WriteLn ('x= ', x1)
  20. end
  21. else
  22. begin
  23. d:=b*b-4*a*c;
  24. if d<0
  25. then WriteLn('Нет вещественных корней')
  26. else
  27. begin
  28. x1:=(-b+sqrt(d))/2/a;
  29. x2:=(-b-sqrt(d))/2/a;
  30. WriteLn('x1=', x1);
  31. WriteLn('x2=', x2)
  32. end
  33. end
  34. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement