C语言高手进,帮下忙啊!

来源:百度知道 编辑:UC知道 时间:2024/05/03 22:48:06
#include<stdio.h>
#include<math.h>
#define C 1550
#define a1 10
#define a2 23
#define r 1.2f
#define q 0.37f
#define c 0.35f
#define f 100f

void main()
{
float respiration(int a,float b);
float operation(int d,float e);
float Q,Q1,Q2,K,L,J,P,F;
int M;
float T,t,t1,t2,t3=25;

printf("please intput the following argument:M,F,J,P,L,t1,t2\n");
scanf("%d,%f,%f,%f,%f,%f,%f",&M,&F,&J,&P,&L,&t1,&t2);

K=1/(1/a1+1/a2+L/r);
Q1=respiration(M,q);
Q2=operation(f,c);
Q=C*M*(t2-t1)+K*F*(t3+J*P/a2-15)+Q1+Q2;
T=Q/(K*F);
t=t2-T;
printf("%d\n",t);

}
float respiration(int a,float b)
{
float z;
z=a*b/1000.0f;
return(z);
}
float operation(int d,float e)
{
float w;
w=3*d*e+470;
return(w);
}
为什么运行结果是0啊

我输入的值是 10000,100,10

printf("%d\n",t);错了
t是float型的,应该用%f

#define r 1.2f
#define q 0.37f
#define c 0.35f
#define f 100f
你把后面的f去掉看看
我运行了一下,没有错误

麻烦你简述一下你要做什么,这么多变量懒得分析啊

常量定义,各个变量之间的赋值,格式输出等都有问题,自己仔细看看就能解决。

不过我将程序修改后的运行结果是一个很大的负数,请问楼主想要的正确的结果是什么?