Advertisement
Guest User

Untitled

a guest
Oct 24th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4. int main()
  5. {
  6. int a,b,c;
  7. float delta;
  8. cout<<"nhap vao a,b,c"<<endl;
  9. cin >> a;
  10. cin >> b;
  11. cin >> c;
  12. delta=b*b-4*a*c;
  13. if (a==0)
  14. {
  15. if (b!=0)
  16. { cout << "nghiem cua phuong trinh: "<< -float(c)/float(b);
  17. }
  18. else
  19. {
  20. if(c!=0)
  21. {
  22. cout<<"phuong trinh vo nghiem";
  23. }
  24. else
  25. {
  26. cout<<"phuong trinh vo so nghiem";
  27. }
  28. }
  29. }
  30. else
  31. {
  32. if(delta<0)
  33. {
  34. cout<<"phuong trinh vo nghiem";
  35. }
  36. else
  37. {
  38. if(delta==0)
  39. {
  40. cout<<"phuong trinh co 1 nghiem kep x1 = x2 = "<< -float(b)/(2*float(a));
  41. }
  42. else
  43. {
  44. cout<<"nghiem x1 = "<< (-float(b)+ sqrt(delta))/(2*float(a))<<endl;
  45. cout<<"nghiem x2 = "<< (-float(b)- sqrt(delta))/(2*float(a));
  46. }
  47. }
  48. }
  49. return 0;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement