Advertisement
gguuppyy

квадратное уравнение

Sep 27th, 2023
53
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Delphi 0.62 KB | Source Code | 0 0
  1. program ср1;
  2.  
  3. uses
  4.     System.SysUtils;
  5.  
  6. var
  7.     a, b, c, d, x, x1, x2: real;
  8.  
  9. begin
  10.     a := 0;
  11.     b := 0;
  12.     c := 0;
  13.     x := 0;
  14.     x1 := 0;
  15.     x2 := 0;
  16.     writeln('a, b, c');
  17.     readln(a, b, c);
  18.     d := b * b - 4 * a * c;
  19.     if (a = 0) then
  20.         writeln('no')
  21.     else if (d < 0) then
  22.         writeln('no')
  23.     else if (d = 0) then
  24.     begin
  25.         x := -b / (2 * a);
  26.         writeln('x =', x);
  27.     end
  28.     else
  29.     begin
  30.         x1 := (-b + sqrt(d)) / (2 * a);
  31.         x2 := (-b - sqrt(d)) / (2 * a);
  32.         writeln('x1 =', x1);
  33.         writeln('x2 =', x2);
  34.     end;
  35.     readln;
  36.  
  37. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement