#include<iostream>
#include<cstdlib>
#include<cmath>
using namespace std;
class Root
{
public:
double a,b,c,d,e;
double set_fangcheng(){cin>>a>>b>>c;};
double get_d(){d=b*b-4*a*c;};
double get_e(){e=sqrt(d);};
double m(){cout<<"请依次输入二次、一次、常数项:"<<endl;}
double n(){cout<<"a="<<a<<"\t b="<<b<<"\t c="<<c<<endl;};
double f(){cout<<"方程式是:\t"<<a<<"*x*x+"<<b<<"*x+"<<c<<"=0"<<endl;};
}
main()
{
Root s;
double a,b,c,d,e;
s.set_fangcheng();
s.get_d();
s.get_e();
s.m();
s.n();
s.f();
double x1=(-b+e)/(2*a);
double x2=(-b-e)/(2*a);
cout<<"x1="<<x1<<endl;
cout<<"x2="<<x2<<endl;
system("pause");
}
回答后,请用编译器运行一下。谢谢
你修改后的运行结果为\vs2010编程\1991\1991\1991.cpp(17): error C4430: 缺少类型说明符 - 假定为 int。注意: C++ 不支持默认 int
怎样能编译成功。
main 改成 int main 或者
error C3874: “main”的返回类型应为“int”而非“Root”,怎样...
voidm(){cout<<"请依次输入二次、一次、常数项:"<<endl;} void n(){cout<<"a="<<a<<"\\t b="<<b<<"\\t c="<<c<<endl;};void f(){cout<<"方程式是:\\t"<<a<<"*x*x+"<<b<<"*x+"<<c<<"=0"<<endl;};};main(){ Root s;double a,b,c,d,e;s.set_fang...