Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. //
  2. // Created by User on 09.11.2019.
  3. //
  4.  
  5. #include <cmath>
  6. #include <iostream>
  7.  
  8. using namespace std;
  9.  
  10. int main() {
  11.  
  12. float a, b, c, x1, x2, x3;
  13. cin >> a >> b >> c;
  14. float D = (b * b) - (4 * a * c);
  15.  
  16.  
  17. if (a == 0 && c == 0 && b != 0)
  18. cout << endl;
  19. else if (a == 0 && b == 0 && c != 0)
  20. cout << endl;
  21. else if (b == 0 && c == 0 && a != 0)
  22. cout << endl;
  23. else if (a == 0 && b == 0 && c == 0)
  24. cout << endl;
  25. else if(a != 0 && b != 0 && c == 0){
  26. x1 = (-b + sqrt(D)) / (2 * a);
  27. x2 = (-b - sqrt(D)) / (2 * a);
  28. cout << x1 << " " << x2;
  29. }
  30.  
  31. else if (a == 0 && b != 0 && c != 0) {
  32. x3 = (-c) / b;
  33. cout << x3;
  34. } else if (a != 0 && b != 0 && c != 0) {
  35. D >= 0;
  36. x1 = (-b + sqrt(D)) / (2 * a);
  37. x2 = (-b - sqrt(D)) / (2 * a);
  38. if (x1 == x2) {
  39. cout << x1;
  40.  
  41. } else if (D < 0) {
  42. cout << endl;
  43. } else
  44. cout << x1 << " " << x2;
  45. }
  46. return 0;
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement