Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- void GetRoot(double a, double b, double c) {
- double discriminant = b * b - 4 * a * c;
- if (discriminant < 0) {
- cout << "Уравнение не имеет корней" << endl;
- return;
- }
- double x1 = (-b + sqrt(discriminant)) / (2 * a);
- double x2 = (-b - sqrt(discriminant)) / (2 * a);
- cout << "x1 = " << x1 << ", x2 = " << x2 << endl;
- }
- void GetRoot(double a, double b) {
- double x = - b / a;
- cout << "x = " << x << endl;
- }
- int main() {
- setlocale(LC_ALL, "ru");
- GetRoot(2, 6, 4);
- GetRoot(6, 2, 4);
- GetRoot(6, -2);
- GetRoot(6, 5);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement