#30148: 測資成功卻有一題過不了


mephistoxfaust@gmail.com (舟梅浮永不逆)


#include<iostream>
#include <math.h>
using namespace std;

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

求問執行時最後一題過不了 為何

#30153: Re: 測資成功卻有一題過不了


cges30901 (cges30901)



    d = ((-b + (sqrt((b*b)-(4*a*c))))/2*a);
    e = ((-b - (sqrt((b*b)-(4*a*c))))/2*a);
    
    


2*a要括號