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