65,187
社区成员




#include<iostream>
#include<math.h>
#define e 2.7182818245
int main()
{
using namespace std;
double a=0,b=1,error=0.005;
double y0,y1,x;
int count=0;
do
{
x=(a+b)/2;
y0=pow(e,a)+10*a-2;
y1=pow(e,x)+10*x-2;
if(y0*y1>0)
a=x;
else
b=x;
count++;
}while((b-a)<error);
cout<<"x="<<x<<endl;
cout<<"count="<<count<<endl;
cin.get();
return 0;
}