Polnochniy

Untitled

Nov 6th, 2019
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. #include <iostream>
  2. #include <math.h>
  3. using namespace std;
  4. double disk(double q, double w, double e)
  5. {
  6. double d;
  7. d = w * w - 4 * q * e;
  8. return d;
  9. }
  10. int main()
  11. {
  12. setlocale(LC_ALL, "Rus");
  13. double a, b, c, x1, v, x2;
  14. cout << " Введите a \n ";
  15. cin >> a;
  16. cout << " Введите b \n ";
  17. cin >> b;
  18. cout << " Введите c \n ";
  19. cin >> c;
  20. v = disk(a, b, c);
  21. if (v > 0)
  22. {
  23. x1 = (-b + sqrt(v)) / (2 * a);
  24. x2 = (-b - sqrt(v)) / (2 * a);
  25. cout << " Уравнение имеет два корна " << endl;
  26. cout << x1 << " " << x2;
  27. }
  28. else if (v == 0)
  29. {
  30. x1 = -b / (2 * a);
  31. cout << "Уравнение имеет один корень" << endl;
  32. cout << x1 << endl;
  33. }
  34. else
  35. {
  36. cout << "Корней нет" << endl;
  37. }
  38. return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment