Advertisement
Guest User

Untitled

a guest
Jul 20th, 2017
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.94 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <iomanip>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. double a, b, c, d, x1, x2;
  10. cin >> a >> b >> c;
  11. d = b*b - 4*a*c;
  12. if (a == 0)
  13. if (b == 0)
  14. if (c == 0) cout << -1;
  15. else cout << 0;
  16. else
  17. {
  18. cout << 1 << endl;
  19. cout << setprecision(6) << c*(-1)/b;
  20. }
  21. else
  22. if (d < 0)
  23. {
  24. cout << 0;
  25. }
  26. else
  27. if (d == 0)
  28. {
  29. cout << 1 << endl;
  30. x1 = (b*(-1) + sqrt(d))/(2*a);
  31. cout << setprecision(6) << x1;
  32. }
  33. else
  34. {
  35. cout << 2 << endl;
  36. x1 = (b*(-1) - sqrt(d))/(2*a);
  37. x2 = (b*(-1) + sqrt(d))/(2*a);
  38. cout << setprecision(6) << x1 << endl;
  39. cout << setprecision(6) << x2;
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement