一元二次方程求解c语言源程序
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/20 02:18:46
你声明的变量a,b,c都为double,所以用scanf时应用"%lf",还有,你为什么要用do{}while();循环呢,这样,不管你输入了a的值为多少,执行完while(a=0);之后,a的值就为
#include"stdio.h"#include"math.h"/*求一元二次方程ax*x+bx+c=0的解*/main(){floata,b,c,x1,x2,d;printf("请输入a:");s
//只一处有错,还有一个注意输入格式.#include#includeintmain(){doublep,q,x1,x2,disc,a,b,c;scanf("%lf,%lf,%lf",&a,&b,&c
intmain()printf("请输入a,b,c");{scanf("%d%d%d",a,b,c);intx1,x2;inty=sqrt(b*b-4*a*c);if(y>0){x1=(-b+y)/2
scanf("%f,%f,%f",a,b,c);a,b,c前加个&符号还有x1=(e-b)/2a,要x1=(e-b)/(2*a)
lf%错了,应该是%lf
很高兴为您解答.原代码中的scanf和printf中的%要放在d和lf的前面才对,改正后运算无误~#include#includevoidmain(){doublex1;//x1,x2分别为方程的2个
(1)当b²-4ac
double改做float再问:yiyuanercifangcheng.cpp(25):warningC4244:'=':conversionfrom'int'to'float',possiblelo
#include#includeintmain(){doublea,b,c,disc,p,q,x1,x2;scanf("%lf%lf%lf",&a,&b,&c);disc=b*b-4*a*c;if(a
#includefloatf(float);voidmain(){floata,b,c,d,x1,x2,p,q;printf("a=");scanf("%f",&a);printf("b=");sca
#include#includeintmain(){inta,b,c,m;doublex1,x2,n;//解为double类型printf("请输入ax2+bx+c=0中的a,b,c:\n");sca
#include#includevoidm(floata,floatb,floatc){\x09doublex1,x2;\x09x1=(-b+sqrt(b*b-4*a*c))/(2*a);\x09x2
/*结束程序请按“Ctrl+z”*/#include#includeintmain(){floata,b,c;doubled,x1,x2;printf("Enterthecoefficient
矩阵问题:求出x1^2x2^2x3^2x1x2x3111的逆矩阵,用这个逆矩阵右乘(y1,y2,y2),就分别的a,b,c
double类型的不能直接用==0来判断,用fabs(a)
#include#include#includevoidmain(){floata,b,c,x1,x2,delta;intflag;printf("a=");scanf("%f",&a);printf
#include#includevoidmain(){floata,b,c,disc,x1,x2,realpart,imagpart;scanf("%f,%f,%f",&a,&b,&c);disc=b
#include#includeusingnamespacestd;#defineMaxsize50classstack{private:char*st;inttop;public:stack(
#include"stdio.h"#include"math.h"#include"windows.h"voidmain(){floata,b,c;printf("----计算一元二次方程ax^2+b