#2540: 为什么输入1 0 0输出无解啊


chenzl93 (haha123)


#include<iostream>
#include<cmath>
using namespace std;
int main()
{
    double a,b,c,d;
   
    while(cin>>a>>b>>c)
    {d=(b*b)-(4*a*c);
    if(d>0)
    cout<<"Two different roots x1="<<(int)((-b+sqrt(d))/(2*a))<<",x2="<<(int)((-b-sqrt(d))/(2*a))<<endl;
       else if(d=0)  cout<<"Two same roots x="<<(int)(-b/2/a)<<endl;
       else   cout<<"NO real roots"<<endl;
 
     }
               
}
#2547: Re:为什么输入1 0 0输出无解啊


leopan0922 (zz)


#include
#include
using namespace std;
int main()
{
    double a,b,c,d;
   
    while(cin>>a>>b>>c)
    {d=(b*b)-(4*a*c);
    if(d>0)
    cout<<"Two different roots x1="<<(int)((-b+sqrt(d))/(2*a))<<",x2="<<(int)((-b-sqrt(d))/(2*a))<       else if(d==0)  cout<<"Two same roots x="<<(int)(-b/2/a)<       else   cout<<"NO real roots"< 
     }
               
}
少個等於
#2548: Re:为什么输入1 0 0输出无解啊


chenzl93 (haha123)


多谢多谢