刚开始学C语言,大家看看这段程序哪出错了
#include<stdio.h>
#include<math.h>
int main(void)
{
int a =1;
int b =2;
int c =3;
double delta;
double x1;
double x2;
delta=b*b-4*a*c;
if (delta>0);
{
x1=(-b+sqrt(delta))/2*a;
x2=(-b-sqrt(delta))/2*a;
printf("该一元二次方程有两解,x1=%f,x2=%f\n",x1,x2,);
}
else if (delta==0)
{
x1=(-b)/2*a;
x2=x1;
printf("该一元二次方程有两解,x1=x2=%f\n",x1);
}
if (delta<0)
{
printf("无解");
}
[展开]
P***
2011-09-18 16:24:31
举报