求指正!!!我的程序错在哪里,怎样改正
本人编写一个关于问题“求出ax2+bx+c=0和a1x2+b1x+c1=0两个曲线的交点,a,b,c,a1,b1,c1由键盘输入,如没有交点,则改变系数从新输入,直到求出交点。并在屏幕上画出这两条曲线。”的程序,但是每次运行都显示错误,求大神帮忙指正修改!!!!源程序如下:
#include<stdio.h>
#include<math.h>
#include<graphics.h>
void draw_xy()
{
setcolor(RED);
line(50,200,300,200);
outtextxy(300,198,">");
line(175,50,175,400);
outtextxy(172,49,"\136");
}
main()
{
float a,b,c,a1,b1,c1,i,j,k,x1,x2,y1,y2,disc;
int h;
int graphdriver=DETECT,graphmode,x;
initgraph(&graphdriver,&graphmode,"");
cleardevice();
printf("please input six number,\n");
scanf("%f,%f,%f,%f,%f,%f",&a,&b,&c,&a1,&b1,&c1);
i=a-a1;j=b-b1;k=c-c1;disc=j*j-4*i*k;
for(h=1;;h++)
{
if(((fabs(a-a1)<1e-6)&&(fabs(b-b1)<1e-6)&&(c!=c1))||(disc<0))
{
printf("have no point\nplease scanf six number again\n");
scanf("%f,%f,%f,%f,%f,%f",&a,&b,&c,&a1,&b1,&c1);
}
else
break;
}
if(fabs(a-a1)<=1e-6)
{
if(fabs(b-b1)<=1e-6)
{
if(fabs(c-c1)<1e-6)
printf("two curve coincide\n");
}
else
{
x1=(c-c1)/(b-b1);
y1=a*x1*x1+b*x1+c;
printf("have one point(%.4f,%.4f)\n",x1,y1);
}
}
else
{
if(fabs(disc)<=1e-6)
{
x1=-j/(2*i);
y1=a*x1*x1+b*y1+c;
printf("have one point(%.4f,%.4f)\n",x1,y1);
}
else
{
if(disc>0)
{
x1=(-j+sqrt(disc))/(2*i);
x2=(-j-sqrt(disc))/(2*i);
y1=a*x1*x1+b*x1+c;
y2=a*x2*x2+b*x2+c; printf("havetwopoint(%.4f,%.4f),(%.4f,%.4f)\n",x1,y1,x2,y2);
}
}
}
getch();
draw_xy();
for(x1=-40;x1<=40;x1=x1+0.0001)
putpixel(175+x1,200-(a*x1*x1+b*x1+c),3);
for(x2=-40;x2<=40;x2=x2+0.0001)
putpixel(x2+175,200-(a1*x2*x2+b1*x2+c1),3);
getch();
}