#include<graphics.h>
int main()
{
int x1,y1,x2,y2,x,y,dx,dy;
int xmin,xmax,ymin,ymax;
float u,p,q;
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc");
xmin=ymin=100;
xmax=ymax=300;
x1=150;y1=150; x2=350; y2=200;
rectangle(xmin,ymin,xmax,ymax);
line(x1,y1,x2,y2);
u=(float)(xmax-x1)/(x2-x1);
dx=x2-x1;
dy=y2-y1;
x=x1+(int)(dx*u);
y=y1+(int)(dy*u);
getch();
cleardevice();
rectangle(xmin,ymin,xmax,ymax);
line(x1,y1,x,y);
getch();
return 0;
}
int main()
{
int x1,y1,x2,y2,x,y,dx,dy;
int xmin,xmax,ymin,ymax;
float u,p,q;
int gd=DETECT,gm;
initgraph(&gd,&gm,"c:\\tc");
xmin=ymin=100;
xmax=ymax=300;
x1=150;y1=150; x2=350; y2=200;
rectangle(xmin,ymin,xmax,ymax);
line(x1,y1,x2,y2);
u=(float)(xmax-x1)/(x2-x1);
dx=x2-x1;
dy=y2-y1;
x=x1+(int)(dx*u);
y=y1+(int)(dy*u);
getch();
cleardevice();
rectangle(xmin,ymin,xmax,ymax);
line(x1,y1,x,y);
getch();
return 0;
}
No comments:
Post a Comment