求根公式的c语言表达式是什么?

Python023

求根公式的c语言表达式是什么?,第1张

求根公式的c语言程序如下:

#include<stdio.h>

#include<math.h>

int main()

{

float x1,x2,,a,b,c

float deta

scanf("%f,%f,%f",&a,&b,&c)

deta=b*b-4*a*c

if(deta<0)

{

printf("方程无解")

}

else

{

x1=(-b+sqrt(deta))/(2*a)

x2=(-b-sqrt(deta))/(2*a)

printf("x1=%f,x2=%f",x1,c2)

}

return 0

}

首先在 main()函数 上边加个#include "math.h" 因为开根号属于 数学函数里边的函数,要使用根号就要加上#inculde "math.h",\r\n然后在你要开根号的数的前边加个 sqrt,就可以了 \r\n例如\r\n#inculde "math.h"\r\nmain()\r\n{ float a,b\r\n printf("please input a nuberm:")\r\n scanf("%f",&a)\r\n b=sqrt(a)\r\n printf("%f\n",b)\r\n \r\n}这个程序就是 让 用户输入个数字,然后输出原数值的开根号后的结果