Advertisement
Guest User

Quadratic Equation

a guest
Jan 17th, 2016
999
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. #include<iostream>
  2. #include<cmath>
  3. using namespace std;
  4. int main()
  5. {
  6. double a,b,c,d,D1,e,f,l;
  7. double D;
  8. int x1,x2;
  9. cout<<"made by Y.Strike\n";
  10. cout<<"vavedi a\n";
  11. cin>>a;
  12. cout<<"vavedi b\n";
  13. cin>>b;
  14. cout<<"vavedi c\n";
  15. cin>>c;
  16. if(a<=0)
  17. {
  18. d=a*(-1);
  19. e=b*(-1);
  20. f=c*(-1);
  21. D=(e*e)-(4*d*f);
  22. }
  23. else
  24. {
  25. D=(b*b)-(4*a*c);
  26. }
  27. if(D<=0)
  28. {
  29. cout<<"nqma koreni(diskriminanta po malko ot 0)\n";
  30. system("pause");
  31. return 0;
  32. }
  33. else
  34. l=sqrt(D);
  35. x1=(-b+l)/(2*a);
  36. x2=(-b-l)/(2*a);
  37. if(x1==0)
  38. {
  39.     cout<<"uravnenieto ima samo edin koreen  X2="<<x2<<endl;
  40.     system("pause");
  41.     return 0;
  42. }
  43. else
  44. {
  45.     cout<<"  X1="<<x1<<"  X2="<<x2<<endl;
  46.     system("pause");
  47. return 0;
  48. }
  49. system("pause");
  50. return 0;
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement