Advertisement
Guest User

Untitled

a guest
Nov 21st, 2014
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4. int main()
  5. {
  6. double a,b,c,delta,x1,x2;
  7. cout<<"podaj wyznaczniki a, b i c:"<<endl;
  8. cin>>a>>b>>c;
  9. if (a!=0) {
  10. delta=(b*b)-(4*a*c);
  11. if (delta!=0) {
  12. x1=(-b-sqrt(delta))/(2*a);
  13. x2=(-b+sqrt(delta))/(2*a);
  14. } else {
  15. x1=(-b)/(2*a);
  16. x2=0;
  17. }
  18. } else {
  19. x1=(-c)/b;
  20. x2=0;
  21. }
  22.  
  23. if (x2!=0) {
  24. cout<<"x wynosi"<<x1<<" lub "<<x2<<endl;
  25. } else {
  26. cout<<"to nie jest rΓ³wnanie kwadratowe, x wynosi "<<x1<<endl;
  27. }
  28.  
  29.  
  30.  
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement