以下是我寫的,但都只有8可以幫忙解答嗎解答嗎?謝謝!
#include <iostream>
#include <math.h>
using namespace std;
int main()
{
int a,b,c,x1,x2;
cin>>a>>b>>c;
x1=(-1*b+sqrt(b*b-4*a*c))/2*a;
x2=(-1*b-sqrt(b*b-4*a*c))/2*a;
if(b*b-4*a*c<0)
{
cout<<"No real root"<<endl;
}
else if(b*b-4*a*c==0)
{
cout<<"Two same roots x="<<x1<<endl;
}
else
{
cout<<"Two different roots x1="<<x1<<" , x2="<<x2<<endl;
}
}
以下是我寫的,但都只有80%可以幫忙解答嗎解答嗎?謝謝!
#include
#include
using namespace std;
int main()
{
int a,b,c,x1,x2;
cin>>a>>b>>c;
x1=(-1*b+sqrt(b*b-4*a*c))/2*a;
x2=(-1*b-sqrt(b*b-4*a*c))/2*a;
if(b*b-4*a*c<0)
{
cout<<"No real root"< }
else if(b*b-4*a*c==0)
{
cout<<"Two same roots x="< }
else
{
cout<<"Two different roots x1="<