#include <iostream>
#include<math.h>
using namespace std;
int main(){
int a,b,c;
float x1,x2;
cin>>a>>b>>c;
if(pow(b,2)-4*a*c>0){
x1=(float)(-b+sqrt(pow(b,2)-4*a*c))/2*a;
x2=(float)(-b-sqrt(pow(b,2)-4*a*c))/2*a;
cout<<"Two different roots "<<"x1="<<x1<<" , "<<"x2="<<x2;
}
else if(pow(b,2)-4*a*c==0){
x1=(float)-b/2*a;
cout<<"Two same roots x="<<x1;}
else{
cout<<"No real root";}
return 0;
}
#include
#include
using namespace std;
int main(){
int a,b,c;
float x1,x2;
cin>>a>>b>>c;
if(pow(b,2)-4*a*c>0){
x1=(float)(-b+sqrt(pow(b,2)-4*a*c))/2*a;
x2=(float)(-b-sqrt(pow(b,2)-4*a*c))/2*a;
cout<<"Two different roots "<<"x1="<<x1<<" , "<<"x2="<<x2;
}
else if(pow(b,2)-4*a*c==0){
x1=(float)-b/2*a;
cout<<"Two same roots x="<<x1;}
else{
cout<<"No real root";}
return 0;
}
2*a要括號