Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // homework 3
- // ex 1
- #include <iostream>
- #include <cmath>
- using namespace std;
- int main()
- {
- double a;
- double b;
- double c;
- cout<<"a=";
- cin>>a;
- cout<<"b=";
- cin>>b;
- cout<<"c=";
- cin>>c;
- double d;
- d=b*b-4*a*c;
- cout<<"D="<<d<<endl;
- if(d<0)
- {
- cout<<"D<0 roots net"<<endl;
- }
- if(d==0)
- {
- cout<<"D=0 roots est' odin"<<endl;
- double x;
- x=-b/(2*a);
- cout<<"x="<<x<<endl;
- }
- if(d>0)
- {
- cout<<"D>0 roots est' dva"<<endl;
- double x;
- double z;
- x=(-b+sqrt(b))/(2*a);
- cout<<"x1="<<x<<endl;
- z=(-b-sqrt(b))/(2*a);
- cout<<"x2="<<z<<endl;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement