老师留的计算化学中的C 语言编程题不会~!求高手帮忙~!

来源:百度知道 编辑:UC知道 时间:2024/05/07 03:51:39
用 C 语言编程:
1.用对分法(0.618法)求出方程2X3+3X2-17X-30=0 在区间[1,10]区间的解, ε =0.01
2.在浓度为1.0×10-5 mol/L(或1.0×10-6mol/L)的Hac水溶液中,考虑水的解离,用牛顿法计算其氢离子的浓度和PH。
已知:Ka=1.80×10-5,Kw=1.0×10-14,ε =1.0×10-6

那个上面的是不是2x^3+3x^2-17x-30=0

1 #include<stdio.h>
void main()
{
double a,b,c,m,n,y;
scanf("%lf%lf",&a,&b);/*注意要使f(a)>0,f(b<0)*/
for(;a-b<=0.01;)
{m=2*pow(a,3)+3*pow(a,2)-17*a-30;
n=2*pow(b,3)+3*pow(b,2)-17*b-30;
c=(a+b)/2;
y= 2*pow(c,3)+3*pow(c,2)-17*c-30;
if(y>0)
a=c;
else
b=c;}
printf("%ld",c);
}

2

hj