简单的C程序~~不知错在哪里

来源:百度知道 编辑:UC知道 时间:2024/05/22 17:44:28
#include<stdio.h>
#include<math.h>
main()
{
float a,b,c,x1,x2,dt,p,q;
printf("请输入a,b,c的值");
scanf("%f%f%f",&a,&b,&c);
dt=sqrt(b*b-4*a*c);
p=-b/(2*a);
q=dt/(2*a);
x1=p+q;
x2=p-q;
printf("方程%6.2fx*x+%6.2fx+%6.2f=0的值",a,b,c);
printf("x1=%f,x2=%f\n",x1,x2);
}

printf("方程%6.2fx*x+%6.2fx+%6.2f=0的值",a,b,c);
这行有一个中文逗号。
其它应该没有错吧。

如果在Linux下面使用gcc编译,需要link一下math库,如下:
cc -o findroot findroot.c -lm
之后可以运行
./findroot

不过这个程序写的真是很有初学者风范:)
大家不要效仿。

如果有其它编译错误,直接贴上来。

对就是多了个,

其他的没有了