Está en la página 1de 1

//Quispe Ticona, Manuel Alonso

//Raices de la ecuacion ax+bx+c=0


#include<iostream>
#include<stdlib.h>
#include<math.h>
#include<time.h>
using namespace std;
int main(){
srand((unsigned)time(NULL));
float a,b,c,X;
a=rand()%21;
b=rand()%21;
c=rand()%21;
cout<<"a: "<<a<<endl
<<"b: "<<b<<endl
<<"c: "<<c<<endl;
if(a==0){
X=(-b)/c;
cout<<"X="<<X<<endl;
}
else if(pow(b,2)<4*a*c){
cout<<"No existe solucion\n";
}
else if(pow(b,2)==4*a*c){
X=(-b)/(2*a);
cout<<"X:"<<X<<endl;
}
else{

cout<<"X1:"<<(-b+sqrt(pow(b,2)-4*a*c))/(2*a)<<endl;
cout<<"X2:"<<(-b-sqrt(pow(b,2)-4*a*c))/(2*a)<<endl;
}

system("pause");
}

También podría gustarte