SHARE
TWEET

Untitled

a guest Oct 13th, 2019 63 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <iostream>
  2. #include <vector>
  3. #include <string>
  4. using namespace std;
  5.  
  6. class A {
  7. public:
  8.     float a;
  9. };
  10.  
  11. class B {
  12. public:
  13.     float b;
  14. };
  15.  
  16. class C {
  17. public:
  18.     float c;
  19. };
  20.  
  21. class X: public A, public B, public C {
  22. public:
  23.     float D, x, x1, x2;
  24.     X() {
  25.         a = b = c = 0;
  26.     }
  27.     /*X(float a_num, float b_num, float c_num) {
  28.         a = a_num;
  29.         b = b_num;
  30.         c = c_num;
  31.     }*/
  32.     void Solution() {
  33.         cout << "Решение квадратного уравнения" << endl << "Введите переменные a, b и c" << endl;
  34.         cin >> a >> b >> c;
  35.         D = b * b - 4 * a * c;
  36.         cout << "Дискриминант равен " << D << endl;
  37.         if (D < 0)
  38.             cout << "Уравнение не имеет решений" << endl;
  39.         if (D == 0)
  40.         {
  41.             cout << "Уравнение имеет одно решение" << endl;
  42.             x = -b / (2 * a);
  43.             cout << "x=" << x;
  44.         }
  45.         if (D > 0)
  46.         {
  47.             cout << "Уравнение имеет два решения" << endl;
  48.             x1 = (-b + sqrt(D)) / (2 * a);
  49.             x2 = (-b - sqrt(D)) / (2 * a);
  50.             cout << "x1=" << x1 << ", " << "x2=" << x2 << endl;
  51.         }
  52.     }
  53. };
  54.  
  55. int main()
  56. {
  57.     setlocale(LC_ALL, "Russian");
  58.     X *uravnenie = new X();
  59.     uravnenie->Solution();
  60. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top