666


私信TA

用户名:666dff

访问量:11675

签 名:

等  级
排  名 559
经  验 4225
参赛次数 1
文章发表 66
年  龄 3
在职情况 学生
学  校
专  业

  自我简介:

解题思路:

注意事项:

参考代码:

#include<stdio.h>

#include<math.h>

void qiugen(double a,double b,double c)

{

double d,x1,x2;

d=b*b-4*a*c;

if(d==0)

{

x1=-b/(2*a);

x2=x1;

printf("x1=%.3f x2=%.3f\n",x1,x2);

}

else if(d>0)

{

x1=(-b+pow(d,0.5))/(2*a);

        x2=(-b-pow(d,0.5))/(2*a);

printf("x1=%.3f x2=%.3f\n",x1,x2);

}

else

{

printf("x1=%.3f+%.3fi ",-b/(2*a),sqrt(4*a*c-b*b)/(2*a));

printf("x2=%.3f-%.3fi",-b/(2*a),sqrt(4*a*c-b*b)/(2*a));

}

printf("\n");

}

int main()

{

double a,b,c;

scanf("%lf %lf %lf",&a,&b,&c);

qiugen(a,b,c);

return 0;

}


 

0.0分

5 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换

万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区

#include<stdio.h>
#include<math.h>
int main()
{
    double a,b,c,d,x1,x2;
    scanf("%lf %lf %lf",&a,&b,&c);
    d=b*b-4*a*c;
    if(d>=0)
    {
    	x1=(-b+sqrt(d))/(2*a);
    	x2=(-b-sqrt(d))/(2*a);
    	printf("x1=%.3lf x2=%.3f\n",x1,x2);
	}
	else
	{
		x1=-b/(2*a);
    	x2=sqrt(-d)/(2*a);
    	printf("x1=%.3lf+%.3lfi",x1,x2);
    	printf("x2=%.3lf-%.3lfi\n",x1,x2);	
	}
	return 0;
}为啥我过不了,答案没问题啊
2021-12-12 10:37:17
  • «
  • 1
  • »