#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main () {
int a , b , c ;
while ( cin >> a >> b >> c ) {
int D = (b*b)-(4*a*c) ;
int d = sqrt (D) ;
if ( D<0 ) cout << "No real root" << endl ;
if ( D==0 ) cout << "Two same roots x=" << -b/2*a << endl ;
if ( D>0 ) cout << "Two different roots x1=" << (-b+d)/2*a << " , x2=" << (-b-d)/2*a << endl ;
}
return 0 ;
}
#include
#include
#include
using namespace std;
int main () {
int a , b , c ;
while ( cin >> a >> b >> c ) {
int D = (b*b)-(4*a*c) ;
int d = sqrt (D) ;
if ( D if ( D==0 ) cout << "Two same roots x=" << -b/2*a << endl ;
if ( D>0 ) cout << "Two different roots x1=" << (-b+d)/2*a << " , x2=" << (-b-d)/2*a << endl ;
}
return 0 ;
}
重根有誤 -b 除以 2a
你那樣寫變 -b 除以 2 乘以 a