C++程序设计:求解一元二次方程

程序运行过了,没有问题,记得给分#include#includeclass Equation{\x05float a,b,c;\x05public:\x05float x[2];\x05Equation(float a1=0.0,float b1=0.0,float c1=0.0)\x05{\x05\x05a

#include using namespace std; #include class FindRoot{ private: double a,b,c; FindRoot(double m_a,double m_b,double m_c){ a=m_a;b=m_b;c=m_c;} double root(){ double first,two; first=b/(2*a); if(b*b>4*a*c) two=sqrt(b*b-4*a*c); return (first+two);};

#include<math.h>#include <iostream>#include <sstream>#include <string>#include <cstdlib> using namespace std; std::string ConvertToString(float a); class M{ private: float A; float B; float C; public: M(); Assignment(float a,float b,float c); X(); }; M::

#include<iostream> using namespace std; #include<cmath> class FindRoot{ private: double a,b,c; FindRoot(double m_a,double m_b,double m_c){ a=m_a;b=m_b;c=m_c;} double root(){ double first,two; first=b/(2*a); if(b*b>4*a*c) two=sqrt(b*b-4*a*c)

#include<iostream>#include<math.h> // 开方时要用到using std::cout;using std::cin;using std::endl;#define _TCHAR char#define _tmain main#define OK 0;// 定义RootResult结构体为方程的解struct RootResult{ double x1; double x2; double derta;

#include <iostream>#include <cmath>using namespace std;int main(){ int a,b,c; float x,y; float delta; cout<<"请输入一元二次方程对应常量"<<endl; cin>>a>>b>>c; if(a==0&&b==0&&c!=0) cout<<"方程无根"<<endl; else if(a==0&&b!=0) { x=-c/b;

用求根公式吧:x=[-b±√(b^2-4ac)]/(2a) double a, b, c= 0 ;a= b= c = 0.0 ;while( cin >>a >> b>> c ){double m = b*b - 4*a*c ;m = sqrt(m) ;m /= (2*a) ;double x1, x2 ;x1= x2 = 0.0 ;x1 = -b+m ;x2 = -b-m ;if( x1< x2 )//假设先输出较大解//cout << x2 << endl << x

double a =0;double c =0;double b =0;if(b*b-4*a*c<0){y=sqrt(4*a*c-b*b)/2a;x=(-b)/2a;cout<<"x1:"<<x<<"+"<<y<<"i"<<endl;cout<<"x2:"<<x<<"-"<<y<<"i"<<endl;}else{y=sqrt(b*b-4*a*c)/2a;x=(-b)/2a;cout<<"x1:"<<x<<"+"<<y<<endlcout<<"x2:"<<x<<"-"<<y<<endl}差不多函数体就这个样子 没在用自己的电脑 没编译环境调试自己调调看吧

C++的代码:#include #include void main(void){double a,b,c,d;char ch('y');do{cout<<"请依次输入二次方程ax^2+bx+c=0的系数

#include#includeusing namespace std;class qequation{ double a,b,c;public: qequation(double x=1, double y=0, double z=-1){ a=x; b=y; c=z; } void set_coef(double x, double y, double z){ a=x; b=y; c=z; } void solve_equation(){ double d,x1,x2; d=b*b-4*

相关文档

一元二次方程的c 程序
一元二次方程视频教学
一元二次方程定义
一元二次方程解的定义
一元二次方程例题
一元二次方程的解定义
一元二次方程一般形式
一元二次方程定义教案
pxlt.net
tbyh.net
zmqs.net
9213.net
ltww.net
电脑版