www.gsyw.net > C语言判断一元二次方程

C语言判断一元二次方程

#include "stdio.h"#include "math.h"#include "windows.h" void main() { float a,b,c; printf("----计算一元二次方程 ax^2+bx+c=0的根----\n"); printf("请输入a,b,c的值: "); scanf("%f%f%f",&a,&b,&c); if(a==0) { printf("该方程不是一

#include int main (void){int a; int b; int c; double

#include#includevoid main(){float solut(float a,float b,float c);float a, b,c;printf("input a,b,c");scanf("%f ,%f, %f",&a,&b,&c);printf("x=%10.2f\n",solut(a,b,c));}float solut(

(1)ax^2 + bx + c = 0double x1=(-b+sqrt(a*a-4ac))/2a;double x2=(-b-sqrt(a*a-4ac))/2a;(2)double S=(top+bot)*h/2;

在if语句后面还有 else if语句后面多了分号,16,23行,正确代码:# include # include int main(void){ //把三个系数保存到计算机中 int a = 3; //=不表示相等,表示赋值 int b = 5; int c = 3; double delta;//delta 存放的是 b*b - 4*a*c double x1; //存放一

修改后:#include void main() { double a,b,c,x,z,x1,x2; scanf("%lf,%lf,%lf",&a,&b,&c); z=(b*b-4*a*c); if(z { printf("no have\n"); } else if(z>0) { x1 = (-b+z)/(2*a); x2 = (-b-z)/(2*a); printf("x1=%f,x2=%f\n",x1,x2); } else { x = (-b-z) / (2*a); printf("x=%f\n",x); } }

若b=2a+3c,则一元二次方程ax^+bx+c=0有两个不相等的实数根判别式δ=b^-4ac=(2a+3c)^-4ac=4a^+8ac+9c^=4(a+c)^+5c^≥0当且仅当a=c=0,“=”成立∵a≠0,∴“=”不成立--->δ>0--->方程ax^+bx+c=0有两个不相等的实数根

用C语言编写求一元二次方程根的程序,条件判断的充分,步骤如下:void main() { float a,b,c,delta; scanf("%f%f%f",&a,&b,&c); if(a!=0) { delta=b*b-4*a*c; if(delta==0) printf("x1=x2=%7.2f",-b/(2*a)); else if(delta>0) { printf("x1=%7.2f",(-b+sqrt

#include <stdio.h>#include<math.h> int main(void) { int a,b,c; double X,X1,X2; printf("Input a:"); scanf("%f",&a); printf("Input b:"); scanf("%f",&b); printf("Input c:"); scanf("%f",&c); if (a==0) printf("该方程不是一元二次方程");

网站地图

All rights reserved Powered by www.gsyw.net

copyright ©right 2010-2021。
www.gsyw.net内容来自网络,如有侵犯请联系客服。zhit325@qq.com