fork download
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. main () {
  7. float A, B, C, x, x1, x2, D;
  8. cin >> A >> B >> C;
  9. D = pow(B, 2) - 4 * A * C;
  10. if ((A != 0) && (B != 0) && (C!=0)) {
  11. if (D > 0) {
  12. x1 = (- B + sqrt(D))/(2 * A);
  13. x2 = (- B - sqrt(D))/(2 * A);
  14. cout << x1 << " " << x2;
  15. }if (D == 0) {
  16. x = (- B)/(2 * A);
  17. cout << x;
  18. } if (D < 0) {
  19. cout << " ";
  20. }
  21. } else {
  22. if ((A != 0) && (B != 0) && (C == 0)){
  23. x1 = 0;
  24. x2 = (-B / A);
  25. cout << x1 << " " << x2;
  26. } if ((A != 0) && (B == 0) && (C != 0)){
  27. x1 = sqrt(-C/A);
  28. x2 = -sqrt(-C/A);
  29. cout << x1 << " " << x2;
  30. } if ((A != 0) &&(B == 0) && (C == 0)) {
  31. cout << 0;
  32. } if ((A == 0) && (B != 0) && (C != 0)){
  33. x = -C / B;
  34. cout << x;
  35. } if ((A == 0) && (B != 0) && (C == 0)) {
  36. x = 0;
  37. cout << x;
  38. } if ((A == 0) && (B == 0) && (C !=0)) {
  39. cout << " ";
  40. }
  41. }
  42. return 0;
  43. }
Success #stdin #stdout 0s 16064KB
stdin
Standard input is empty
stdout
Standard output is empty