请懂C语言的来帮我一下,急

来源:百度知道 编辑:UC知道 时间:2024/05/21 07:33:41
#include "math.h"
main()
{
double a,b,c,c1b,c1s,c1m,c2b,c2s,c2m,c3b,c3s,k1,k2,L1,L2,a1,a2,b1,b2,L;
double Q1,Q3,CB1,CS1,CM1,TC1,X1,X2;
printf("a=\n");
scanf("%f",&a);
printf("b=\n");
scanf("%f",&b);
printf("c=\n");
scanf("%f",&c);
printf("c1b=\n");
scanf("%f",&c1b);
printf("c1s=\n");
scanf("%f",&c1s);
printf("c1m=\n");
scanf("%f",&c1m);
printf("c2b=\n");
scanf("%f",&c2b);
printf("c2s=\n");
scanf("%f",&c2s);
printf("c2m=\n");
scanf("%f",&c2m);
printf("c3b=\n");
scanf("%f",&c3b);
printf("c3s=\n");
scanf("%f",&c3s);
printf("k1=\n");
scanf("%f",&k1);
prin

#include <stdio.h>
添加了没有?
还有doulbe类型的对应格式是%lf

你先别想结果,可以用单步调试看看变量分别等于多少,有助于调试。
你的算式太多了,我不想看它是用来干什么的,只是给你提个建议。
对了,你还可以在每一步后面让参数的值输出,看是否与理论值相等。

主要问题有两个:
1.double形对应的是"%lf"而不是"%f",特别是在scanf中,错误的类型对应是不被接受的。
2.你的L没有赋值。

#include "math.h"
main()
{
double a,b,c,c1b,c1s,c1m,c2b,c2s,c2m,c3b,c3s,k1,k2,L1,L2,a1,a2,b1,b2,L;
double Q1,Q3,CB1,CS1,CM1,TC1,X1,X2;
printf("a=\n");
scanf("%lf",&a);
printf("b=\n");
scanf("%lf",&b);
printf("c=\n");
scanf("%lf",&c);
printf("c1b=\n");
scanf("%lf",&c1b);
printf("c1s=\n");
scanf("%lf",&c1s);
printf("c1m=\n");
scanf("%lf",&c1m);
printf("c2b=\n");
scanf("%lf",&c2b);
printf("c2s=\n");
scanf("%lf&qu