Advertisement
TheMagnusRex

Домашняя, 3_1

Oct 5th, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. using namespace std;
  4. int main()
  5. {
  6.     double a,b,c,x1,x2,D;
  7.     cout<<"a=";
  8.     cin>>a;
  9.     cout<<"b=";
  10.     cin>>b;
  11.     cout<<"c=";
  12.     cin>>c;
  13.     D=(b*b)-(4*a*c);
  14.     if (D<0)
  15.         {
  16.         cout<<"ne imeet vesch. resheniy";
  17.     }
  18.     if (D==0)
  19.     {
  20.         x1=(-1*b)/(2*a);
  21.         cout<<"x="<<x1;
  22.     }
  23.     if (D>0)
  24.     {
  25.         x1=((-1*b)+(sqrt(D)))/(2*a);
  26.         x2=((-1*b)-(sqrt(D)))/(2*a);
  27.         cout<<"x1="<<x1<<endl;
  28.         cout<<"x2="<<x2;
  29.     }
  30.     return 0;
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement