金泰滨江花城怎么样:用C言语编程求解一元二次方程,请指点哪里有问题

来源:百度文库 编辑:高校问答 时间:2024/05/09 05:07:13
#include "stdio.h"
#include "math.h"
main()
{
float x1,x2,deita;
int a,b,c;
printf("input a,b,c:\n");
scanf("%d%d%d",&a,&b,&c);
deita=b*b-4*a*c;
if (deita>=0)
x1=(-b+sqrt(deita))/(2*a);
x2=(-b-sqrt(deita))/(2*a);
printf("有二个实数解x1=是",x1);
printf("有二个实数解是x2=",x2);
if (deita<0)
{printf("方程没有实数解:");}
getch();

加上一个结束的大括号“}”试试

第一个if语句要用{}括起来,最后少了个}.