3、0,20)到(40,100)System::VoidForm1_Paint(System::Object^sender,System::Windows::Forms::PaintEventArgs^e){intx1=20,y1=20,x2=40,y2=100;inty;floatdx,dy,k,x;Pen^myPen=gcnewPen(Color::Pink,1.0f);dx=x2-x1;dy=y2-y1;k=dy/dx;x=x1;for(y=y1;y<=y2;y++){Rectangler1=Rectangle(int(x+0.5),y,1,1);e->Graphics->Draw
4、Rectangle(myPen,r1);x=x+1/k;}}②k>1时,y--,x=x-1/k情况(40,100)到(20,20)System::VoidForm1_Paint(System::Object^sender,System::Windows::Forms::PaintEventArgs^e){intx1=40,y1=100,x2=20,y2=20;inty;floatdx,dy,k,x;Pen^myPen=gcnewPen(Color::Pink,1.0f);dx=x2-x1;dy=y2-y1;k=dy/dx;x=x1;for(y=y1;y>=y2;y--){Rectan
5、gler1=Rectangle(int(x+0.5),y,1,1);e->Graphics->DrawRectangle(myPen,r1);x=x-1/k;}}③k<-1时,y--,x=x-1/k情况(20,100)到(40,20)System::VoidForm1_Paint(System::Object^sender,System::Windows::Forms::PaintEventArgs^e){intx1=20,y1=100,x2=40,y2=20;inty;floatdx,dy,k,x;Pen^myPen=gcnewPen(Color::Pink,1.0f);dx=x2
6、-x1;dy=y2-y1;k=dy/dx;x=x1;for(y=y1;y>=y2;y--){Rectangler1=Rectangle(int(x+0.5),y,1,1);e->Graphics->DrawRectangle(myPen,r1);x=x-1/k;}}④k<-1时,y++,x=x+1/k情况(40,20)到(20,100)System::VoidForm1_Paint(System::Object^sender,System::Windows::Forms::PaintEventArgs^e){intx1=40,y1=20,x2=20,y2=100;inty;float
7、dx,dy,k,x;Pen^myPen=gcnewPen(Color::Pink,1.0f);dx=x2-x1;dy=y2-y1;k=dy/dx;x=x1;for(y=y1;y<=y2;y++){Rectangler1=Rectangle(int(x+0.5),y,1,1);e->Graphics->DrawRectangle(myPen,r1);x=x+1/k;}}⑤0