#include<iostream>
#include<cmath>
using namespace std;
int main() {
int a;
int b;
int c;
cin>>a;
cin>>b;
cin>>c;
double x=b*b-4*a*c;
if (x>0) {
double x1 =(-2*b+sqrt(b*b-4*a*c))/2*a;
double x2 =(-2*b-sqrt(b*b-4*a*c))/2*a ;
cout<<"Two different roots x1="<< x1 << ", x2=" << x2 <<endl;
}else if (x==0){
double x1 =(-2*b+sqrt(b*b-4*a*c))/2*a;
cout<<"Two same roots x="<< x1 <<endl;
}else if (x<0){
cout<<"No real root "<<endl;
}
system("pause");
return 0;
}
這是我的程式碼
在devc++上都可以執行
結果送上來是ce
各位大大幫幫忙呀