fork download
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. double a = 1;
  8. double b = 4;
  9. double c = 5;
  10.  
  11. double delta = b*b - 4*a*c;
  12.  
  13. if (delta > 0) {
  14. double x1 = (-b - sqrt(delta)) / (2*a);
  15. double x2 = (-b + sqrt(delta)) / (2*a);
  16. cout << "Dwa pierwiastki:" << endl;
  17. cout << "x1 = " << x1 << endl;
  18. cout << "x2 = " << x2 << endl;
  19. }
  20. else if (delta == 0) {
  21. double x = -b / (2*a);
  22. cout << "Jeden pierwiastek:" << endl;
  23. cout << "x = " << x << endl;
  24. }
  25. else {
  26. cout << "Brak pierwiastkow rzeczywistych" << endl;
  27. }
  28.  
  29. return 0;
  30. }
  31.  
Success #stdin #stdout 0.01s 5256KB
stdin
Standard input is empty
stdout
Brak pierwiastkow rzeczywistych