Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
79
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 <cmath>
  3. using namespace std;
  4.  
  5. void RealRootsQadrEqua(double a, double b, double c)
  6. {
  7. double D = pow(b, 2) - 4 * a * c;
  8. double x1=0;
  9. double x2=0;
  10. if (D < 0)
  11. {
  12. cout << "No real roots";
  13.  
  14. }
  15. else if (D = 0)
  16. {
  17. x1 = -b / (2.0 * a);
  18. cout << x1;
  19. }
  20. else
  21. {
  22. x1 = (-b + sqrt(D)) / 2 * a;
  23. x2 = (-b - sqrt(D)) / 2 * a;
  24. cout << x1 << x2;
  25.  
  26. }
  27. }
  28.  
  29. int main()
  30. {
  31. double a, b, c;
  32. cin >> a >> b >> c;
  33. RealRootsQadrEqua(a, b, c);
  34.  
  35.  
  36. //double x1;
  37. //double x2;
  38. //double D = pow(b, 2) - 4 * a * c;
  39. //x1 = (-b + sqrt(D)) / 2 * a;
  40. //x2 = (-b - sqrt(D)) / 2 * a;
  41. //cout << x1 << x2;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement