Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <math.h>
- using namespace std;
- double disk(double q, double w, double e)
- {
- double d;
- d = w * w - 4 * q * e;
- return d;
- }
- int main()
- {
- setlocale(LC_ALL, "Rus");
- double a, b, c, x1, v, x2;
- cout << " Введите a \n ";
- cin >> a;
- cout << " Введите b \n ";
- cin >> b;
- cout << " Введите c \n ";
- cin >> c;
- v = disk(a, b, c);
- if (v > 0)
- {
- x1 = (-b + sqrt(v)) / (2 * a);
- x2 = (-b - sqrt(v)) / (2 * a);
- cout << " Уравнение имеет два корна " << endl;
- cout << x1 << " " << x2;
- }
- else if (v == 0)
- {
- x1 = -b / (2 * a);
- cout << "Уравнение имеет один корень" << endl;
- cout << x1 << endl;
- }
- else
- {
- cout << "Корней нет" << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment