Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <string>
- using namespace std;
- class A {
- public:
- float a;
- };
- class B {
- public:
- float b;
- };
- class C {
- public:
- float c;
- };
- class X: public A, public B, public C {
- public:
- float D, x, x1, x2;
- X() {
- a = b = c = 0;
- }
- /*X(float a_num, float b_num, float c_num) {
- a = a_num;
- b = b_num;
- c = c_num;
- }*/
- void Solution() {
- cout << "Решение квадратного уравнения" << endl << "Введите переменные a, b и c" << endl;
- cin >> a >> b >> c;
- D = b * b - 4 * a * c;
- cout << "Дискриминант равен " << D << endl;
- if (D < 0)
- cout << "Уравнение не имеет решений" << endl;
- if (D == 0)
- {
- cout << "Уравнение имеет одно решение" << endl;
- x = -b / (2 * a);
- cout << "x=" << x;
- }
- if (D > 0)
- {
- cout << "Уравнение имеет два решения" << endl;
- x1 = (-b + sqrt(D)) / (2 * a);
- x2 = (-b - sqrt(D)) / (2 * a);
- cout << "x1=" << x1 << ", " << "x2=" << x2 << endl;
- }
- }
- };
- int main()
- {
- setlocale(LC_ALL, "Russian");
- X *uravnenie = new X();
- uravnenie->Solution();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement