书上的例题,自己改了一下,编译不通过,高手指教
#include<iostream>#include<cmath>
using namespace std;
int main()
{double a,b,c,q,p,x1,x2;
void serch(double,double,double);
cout<<"Plesse enter a,b,c:"<<endl;
cin>>a>>b>>c;
try
{serch(a,b,c);
}
catch(double d)
{cout<<"error"<<d<<endl;}
void serch(double a,double b,double c)
{ q=(-b)/(2*a);
p=b*b-4*a*c;
if(a==0)throw a;
if(p<0)throw p;
x1=q-sqrt(p)/(2*a);
x2=q+sqrt(p)/(2*a)
cout<<"x1="<<x1<<endl;
cout<<"x2="<<x2<<endl;
}
return 0;