题意:
中已知L,S解h。
分析:
两个方程两个未知数,理论是可解的。解起来有困难,可用二分的方法。
代码:
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double l,n,c,s,r;
while(scanf("%lf%lf%lf",&l,&n,&c)==3){
if(l<0) break;
double mid,low=0.0,high=l/2;
s=(1+n*c)*l;
while(high-low>1e-5){
mid=(low+high)/2;
r=(4*mid*mid+l*l)/(8*mid);
if(2*r*asin(l/(2*r))<s)
low=mid;
else
high=mid;
}
printf("%.3lf\n",low);
}
return 0;
} 原文地址:http://blog.csdn.net/sepnine/article/details/46502351