Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- using namespace std;
- double delta(double a,double b,double c){//Interieur racine
- return ((pow(b,2)-(4 * a * c)) );
- }
- double racine(double a,double b,double c){
- return sqrt (abs (delta(a,b,c)));
- }
- int main() {
- double a,b,c;
- cout<<" a= ";cin>>a;
- cout<<" b= ";cin>>b;
- cout<<" c= ";cin>>c;
- cout <<endl<<a<<"x^2+"<<b<<"x+"<<c<<"=0"<<endl<<endl;
- if (delta(a,b,c)>=0){//Sol.Reel
- cout <<"x1=\t"<<((-b + racine(a,b,c))/(2*a*1.0))<<endl
- <<"x2=\t"<<((-b - racine(a,b,c))/(2*a*1.0))<<endl;
- }else{//Sol.Complexe
- cout <<"x1=\t"<<((-b)/(2*a*1.0)) <<"+"<< racine(a,b,c)/(2*a*1.0)<<'i'<<endl;
- cout <<"x2=\t"<<((-b)/(2*a*1.0)) <<"-"<< racine(a,b,c)/(2*a*1.0)<<'i'<<endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement