编程实现一元二次方程的解 ax^2+bx+c=0

#include "stdafx.h" #include #include using namespace std; int _tmain(int argc, _TCHAR* argv[]) { double a,b,c; double delta; double x1,x2; cout<<"Please input a,b,c:"<>a>>b>>c; if(cin.fail()) { cout<<"Error:bad input!"; return 1; } delta=b*b-4*a*c; if(delta>0) { cout<<"The Equation has two roots:"<

 

编程实现一元二次方程的解 ax^2+bx+c=0_第1张图片

实现算法:

 

#include "stdafx.h" #include #include using namespace std; int sgn(int m) { if(m>=0) return 1; else return -1; } int _tmain(int argc, _TCHAR* argv[]) { double a,b,c; double delta; double q; double x1,x2; cout<<"Please input a,b,c:"<>a>>b>>c; delta=b*b-4*a*c; if(delta>0) { cout<<"The equation has two roots:"<

你可能感兴趣的:(C++)