//求一元二次方程式 ax2+bx+c=0 的根#include#includeusing namespace std;int main(){int a,b,c;cin>>a>>b>>c;if((b*b)<(4*a*c)) cout<<"No real root";if((b*b)==(4*a*c)) cout<<"Two same roots x="<<(0-b)/(2*a);if((b*b)>(4*a*c))cout<<"Two different roots x1="<<((0-b)+sqrt((b*b)-(4*a*c)))/2*a<<" , x2="<<((0-b)-sqrt((b*b)-(4*a*c)))/2*a;return 0;}
((0-b)+sqrt((b*b)-(4*a*c)))/2*a --> ((0-b)+sqrt((b*b)-(4*a*c)))/(2*a)
這樣應該就可以了吧(負也記得改)