- 相关推荐
某IT外企面试题-二分法求方程
//f(x)=RMAX-R+(R-r)*double (cos(0.5*x))+double (sqrt(r*r-(R-r)*(R-r)* sin(0.500*x)* sin(0.500*x)))
请用二分法或其他方法求出解x.要求精度esp=1e-5
其中RMAX,R,r从键盘输入,
某IT外企面试题-二分法求方程
。#include
#include
void get(double RMAX,double R,double r,double x,double y)
{
double m,n,c,p;
double esp=1e-5;
do
{
m=RMAX-R+(R-r)*double (cos(0.5*x))+double (sqrt(r*r-(R-r)*(R-r)* sin(0.500*x)* sin(0.500*x)));
n=RMAX-R+(R-r)*double (cos(0.500*y))+double (sqrt(r*r-(R-r)*(R-r)* sin(0.500*y)*sin(0.500*y)));
c=0.500*(x+y);
p=RMAX-R+(R-r)*double (cos(0.500*c))+double (sqrt(r*r-(R-r)*(R-r)* sin(0.500*c)*sin(0.500*c)));
if(fabs(p)
break;
else if(m*p<0)
{
x=x;
y=c;
}
else if (m*p>0)
{
y=y;
x=c;
}
}while(fabs(y-x)
cout<<\”The value of angle:tt\”<<(x+y)*0.5<
cout<<<\” \”<<<\” \”<<
}
void main()
{
double RMAX,R,r,x,y;
cout<<\”input RMAX,R,r,x,y:\”<
cin>>RMAX;
cin>>R;
cin>>r;
cin>>x;
cin>>y;
get(RMAX,R,r,x,y);
}
【某IT外企面试题-二分法求方程】相关文章:
外企的英文面试题怎么答10-18
求唯美悲伤的句子06-21
求上进励志名言07-08
《简易方程》说课稿10-29
求职动机面试题07-30
有趣而刁钻的面试题10-22
20个经典面试题04-12
宝洁英语面试题03-18
销售行业面试题07-26
知名外企面试经历08-13