请教高手,如何用C语言编程计算这道题呢?

来源:百度知道 编辑:UC知道 时间:2024/05/14 01:43:28
化工原理书中关于换热器衡算的方程,需要试差解,方程是:
4.57ln[(50-c)/10]=40-c
c是出口温度,已知高于25℃但小于50℃
想编一个程序计算,结果不能运行。请教高手指点
我编的程序如下
#include "math.h"
main()
{double a,b,c=25;
double log();
for(;c<=50,c++;)
{a=4.57log(50-c)/10;b=40-c;
if(a==b)
printf("%f",c);}
}
这两个都试了,没结果。最好是连结果一起写上,我好有个参考

有问题
你前面又没函数!
而且式差不匹配!

#include "math.h"
#include"stdio.h"
main()
{double a,b,c=25;
freopen("1.txt","w",stdout);
for(;c<=50,c++;)
{a=4.57*(log)(50-c)/10;b=40-c;
if((a<=b)&&(a>=b-0.1)||(a>=b)&&(a<=b+0.1))
{printf("%lf\n",c);
return 0;}
}
}

/*freopen("1.txt","w",stdout);
是说在同一目录下生成1.txt
里面是答案*/

答案: 39.000000

/*程序我改了下,编译可以过,但结果有问题,那就是你的问题了*/
#include "math.h"
main()
{double a,b,c=25;
double log();
for(;c<=50;c++) /*这行多了;*/
{
a=4.57*log((50-c)/10); /* 这行少了*,以及少了()*/
b=40-c;
if(a==b)
printf("%f",c);

}
}

double型运行的难免有些误差,要使a==b几乎是不可能的,所以不会有输出结果的,当两个数的差特点小时就输出,下面是我的程序,当两个数的差小于10^-6是输出结果

#include<math.h>
#include<stdio.h>
int main()
{