Advertisement
nikolay7minecraft

homework 3-1

Sep 23rd, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.69 KB | None | 0 0
  1. // homework 3
  2. // ex 1
  3. #include <iostream>
  4. #include <cmath>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.   double a;
  11.   double b;
  12.   double c;
  13.  
  14.   cout<<"a=";
  15.   cin>>a;
  16.  
  17.   cout<<"b=";
  18.   cin>>b;
  19.  
  20.   cout<<"c=";
  21.   cin>>c;
  22.  
  23.   double d;
  24.   d=b*b-4*a*c;
  25.   cout<<"D="<<d<<endl;
  26.  
  27.   if(d<0)
  28.   {
  29.       cout<<"D<0 roots net"<<endl;
  30.   }
  31.  
  32.   if(d==0)
  33.   {
  34.       cout<<"D=0 roots est' odin"<<endl;
  35.       double x;
  36.       x=-b/(2*a);
  37.       cout<<"x="<<x<<endl;
  38.   }
  39.  
  40.   if(d>0)
  41.   {
  42.       cout<<"D>0 roots est' dva"<<endl;
  43.       double x;
  44.       double z;
  45.       x=(-b+sqrt(b))/(2*a);
  46.       cout<<"x1="<<x<<endl;
  47.       z=(-b-sqrt(b))/(2*a);
  48.       cout<<"x2="<<z<<endl;
  49.      
  50.   }
  51. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement