↑ 收起筛选 ↑
用C语言编一元二次方程
2021-02-23

#include "stdio.h" #include "math.h" /*求一元二次方程ax*x+bx+c=0的解*/ main() { float a,b,c,x1,x2,d; printf("请输入a:"); scanf("%f",&a); printf("请输入b:"); scanf("%f",&b); printf("请输入c:"); scanf("%f",&c); d=b*b-4*a*c;

#include <stdio.h>#include <math.h>int main(void){ double a,b,c,x1,x2,d; scanf("%lf%lf%lf",&a,&b,&c); d = b * b - 4 * a * c; if(d > 0){ x1 = (-1 * b + sqrt(d)) / (2 * a); x2 = (-1 * b - sqrt(d)) / (2 * a); printf("x1 = %g,x2 = %g\n",x1,x2); }else if(d = 0){ x1 =

#include"stdio.h"#include"stdlib.h"#include"math.h"int main(){double printf("输入二元一次方程的系数a,b,c\n");scanf("%lf %lf %lf",&a,&b,&c);if(a==0){x=c/b;printf("x=%lf\n",x);exit(0);} d=pow(b,2)-4*a*c;if(d>0){printf("有

# include<iostream.h># include<math.h> void main(void) { double a,b,c,x1,x2; cout<<"input a,b,c:"; cin>>a>>b>>c; double s=b*b-4*a*c; if(s>=o) { double sqrtVal=sqrt(s); x1=(-b+sqrtVal)/(2*a); x2=(-b-sqrtVal)/(2*a); cout<<"x1="<<x1<<endl; cout<

1. #include 2. #include 3. int main(void)4. {double a,b,c,x1,x2,d;scanf("%lf%lf%lf",&a,&b,&c);d = b * b - 4 * a * c;if(d > 0)5. {x1 = (-1 * b + sqrt(d)) / (2 * a);x2 = (-1 * b - sqrt(d)) / (2 * a);printf("x1 = %g,x2 = %g\n",x1,x2);}6. else if(d = 0)7. {x1 = x2 = (-

这是我做的#include<stdio.h>#include<math.h> void main() //主函数 { float a,b,c,delta,x,x1,x2,realpart,imagpart; //定义a,b,c,delta,x,x1,x2,x3为浮点型 scanf("%f,%f,%f",&a,&b,&c); //输入二次方程系数a,b,c的值 delta=b*b-4*a*c; if(fabs(a)>=1e-

/*March 25 2014 By 12052010 * TODO: 计算简单的 一元二次方程式的根 */#include<stdio.h> #include<math.h> int main(){ int a,b,c; int fg; do{ printf("\nInput a,b,c:");//输进数字时,采用逗号分隔开来,如:1,2,3 ,且a!=0 scanf("%d,%d,%

//这个小问题, 楼主悬赏分太高了, 试一下下面的程序: #include <stdio.h>#include <math.h> int main() { char *str="求解方程式: ax2 + bx +c =0\n请输入a b c的值, 以空格分隔:"; double a=0, b=0, c=0; double delta=0, x1=0, x2=0; printf( "

C语言编写一程序求解一元二次方程的根:#include<stdio.h> #include<math.h> void m(float a,float b,float c) { double x1,x2; x1=(-b+sqrt(b*b-4*a*c))/(2*a); x2=(-b-sqrt(b*b-4*a*c))/(2*a); printf("方程的根是%.2lf和%.2lf",x1,x2); } void n(float a,float b

延伸阅读: