#include<iostream>
#include<math.h>
using namespace std;
int main()
{
int a,b,c,x,z,y;
while(cin>>a>>b>>c)
{
x=b*b-4*a*c;
if(x>0)
{
z=(-b+sqrt(x))/2*a;
y=(-b-sqrt(x))/2*a;
cout<<"Two different roots x1="<<z<<" , x2="<<y;
}else if(x<0)
{
cout<<"No real root";
}else
{
cout<<"Two same roots x="<<-b/2*a;
}
}
return 0;
}
您的答案為: Two same roots x=-4
正確答案為: Two same roots x=-1
都是顯示這個
#include
#include
using namespace std;
int main()
{
int a,b,c,x,z,y;
while(cin>>a>>b>>c)
{
x=b*b-4*a*c;
if(x>0)
{
z=(-b+sqrt(x))/2*a;
y=(-b-sqrt(x))/2*a;
cout<<"Two different roots x1="< }else if(x<0)
{
cout<<"No real root";
}else
{
cout<<"Two same roots x="<<-b/2*a;
}
}
return 0;
}
您的答案為: Two same roots x=-4
正確答案為: Two same roots x=-1
都是顯示這個
#include
#include
using namespace std;
int main()
{
int a,b,c,x,z,y;
while(cin>>a>>b>>c)
{
x=b*b-4*a*c;
if(x>0)
{
z=(-b+sqrt(x))/2*a;
y=(-b-sqrt(x))/2*a;
cout<<"Two different roots x1="< }else if(x<0)
{
cout<<"No real root";
}else
{
cout<<"Two same roots x="<<-b/2*a;
}
}
return 0;
}
您的答案為: Two same roots x=-4
正確答案為: Two same roots x=-1
都是顯示這個