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