Advertisement
Guest User

Untitled

a guest
Jan 19th, 2018
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8. cout << "Podaj liczbe a: ";
  9. int a, b, c;
  10. cin >> a;
  11. cout << "Podaj liczbe b: ";
  12. cin >> b;
  13. cout << "Podaj liczbe c: ";
  14. cin >> c;
  15. int delta = b*b-4*a*c;
  16. if (delta < 0)
  17. {
  18. cout << "Brak rozwiazan";
  19. }
  20.  
  21. else
  22. {
  23. float pierw = sqrt(delta);
  24. float x1 = (-b-pierw)/2*a;
  25. if (delta == 0)
  26. {
  27. cout << "x = " << x1;
  28. }
  29. else
  30. {
  31. float x2 = (-b+pierw)/2*a;
  32. cout <<"x1 = " << x1 << endl << "x2 = " << x2;
  33. }
  34. }
  35. return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement