Advertisement
Guest User

Untitled

a guest
Feb 21st, 2019
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.65 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4. int main()
  5. {
  6. setlocale (LC_ALL, ".ACP");
  7. float a, b, c;
  8. float D1, x1, x2, D2;
  9. cout << "Введите значения ab + bc + c = 0:" << endl;
  10. cin >> a >> b >> c;
  11. D1 = (b * b) - (4 * a * c);
  12. D2 = sqrt(D1);
  13. if (D2 > 0)
  14. {
  15. x1 = (-1 * (b + D2)) / (2 * a);
  16. x2 = (-1 * (b - D2)) / (2 * a);
  17. cout << "x1 = "<< x1 << endl;
  18. cout << "x2 = "<< x2 << endl;
  19. }
  20. else if (D2 = 0)
  21. {
  22. x1 = (-b + D2) / (2 * a);
  23. cout << "x1 = " << x1 << endl;
  24. }
  25. else if (D2 < 0);
  26. {
  27. cout << "Нет корней" << endl;
  28. }
  29. cin.get();
  30. cin.get();
  31. return 0;
  32.  
  33. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement