下面这个函数里面的for循环可以正常执行,就是执行完死活出不去,大家帮我看看怎么回事?不多说,直接上程序
void Draw_Line(double x0,double y0,double x,double ya) //(x0,y0)为起点坐标,(x,y)为终点坐标,y=k(x-x0)+y0
{
double l,x1,y1,a0,b0,a1,b1,la,lb,y,yx;
unsigned int i,count_l,MC1,MC2;
unsigned char tempx1[16];
y=ya+10;
l=sqrt((x-x0)*(x-x0)+(y-y0)*(y-y0));
count_l=l*2; //分成i份,每份0.5厘米
a0=sqrt((x0+15)*(x0+15)+(115-y0)*(115-y0));
b0=sqrt((95-x0)*(95-x0)+(115-y0)*(115-y0));
for(i=1;i<=count_l;i++)
{
x1=(x-x0)/count_l+x0;
y1=(y-y0)/count_l+y0;
a1=sqrt((x1+15)*(x1+15)+(115-y1)*(115-y1));
b1=sqrt((95-x1)*(95-x1)+(115-y1)*(115-y1));
la=a1-a0;
lb=b1-b0;
if(la>0)
{
MC1=la/0.070;
for(i=0;i<MC1;i++)
stepper3();
}
else
{
MC1=-la/0.070;
for(i=0;i<MC1;i++)
stepper4();
}
if(lb>0)
{
MC2=lb/0.090;
for(i=0;i<MC2;i++)
stepper1();
}
else
{
MC2=-lb/0.090;
for(i=0;i<MC2;i++)
stepper2();
}
yx=ya/y*y1;
sprintf(tempx1,"(%2.1f,%2.1f) ",x1,yx);
Put_String(4,0,tempx1);
x0=x1;
y0=y1;
a0=a1;
b0=b1;
}
Put_String(2,0,"...");
} |