#5006: 請問我錯在哪邊


cse911518 (仆街)


#include<<math.h>>
#include<iostream>
using namespace std;
int main ()
{
    int a,b,c,d,e,f;
    while (cin >> a >> b >> c )
    d=(-b+sqrt(b*b-4*a*c))/2*a
    e=(-b-sqrt(b*b-4*a*c))/2*a
    f=(-b)/2*a
    if (b*b-4*a*c > 0)
    {
         cout << "Two different roots x1="  << d << ", x2=" << e << endl;
    }
    else if (b*b-4*a*c=0)
    {
         cout << "Two same roots x=" << f << endl;
    }
    else
    {
         cout << "No real root" << endl ;
    }
}
     
#5092: Re:請問我錯在哪邊


handsome616 (豆花)


#include<>
#include
using namespace std;
int main ()
{
    int a,b,c,d,e,f;
    while (cin >> a >> b >> c )
    d=(-b+sqrt(b*b-4*a*c))/2*a
    e=(-b-sqrt(b*b-4*a*c))/2*a
    f=(-b)/2*a
    if (b*b-4*a*c > 0)
    {
         cout << "Two different roots x1="  << d << ", x2=" << e << endl;
    }
    else if (b*b-4*a*c=0)
    {
         cout << "Two same roots x=" << f << endl;
    }
    else
    {
         cout << "No real root" << endl ;
    }
}
     

第一行就錯了