Advertisement
Guest User

Untitled

a guest
May 21st, 2018
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3.  
  4. using namespace std;
  5.  
  6. int main() {
  7. float a, b, c, delta, x1, x2;
  8.  
  9. cout << "Podaj a: "; cin >> a;
  10.  
  11. if(a==0) cout << "Równanie nie jest kwadratowe\n";
  12. else
  13. {
  14. cout << "Podaj b: "; cin >> b;
  15. cout << "Podaj c: "; cin >> c;
  16. delta=b*b-4*a*c;
  17. cout << "Delta wynosi: " << delta << endl;
  18. }
  19.  
  20. if(delta>0) {
  21. x1=(-b-sqrt(delta))/(2*a);
  22. x2=(-b+sqrt(delta))/(2*a);
  23. cout << "Pierwszy pierwiastek wynosi: " << x1 << endl;
  24. cout << "Drugi pierwiastek wynosi: " << x2 << endl;
  25. }
  26. else if (delta==0) {
  27. x1=-b/(2*a);
  28. cout << "Pierwiastek podwójny wynosi: " << x1 << endl;
  29. }
  30. else if (delta<0) {
  31. cout << "Równanie nie ma pierwiastków\n";
  32. }
  33.  
  34. return 0;
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement