compilador c online para gráficos
#include <stdio.h>
#include <conio.h>
#include <graphics.h>
#include <math.h>
int main() {
int count = 1, gd = DETECT, gm;
int x, y, dx, dy, inc, x1, y1, x2, y2;
initgraph(&gd, &gm, "..\\BGI");
printf("\nEnter Initial Line Coordinates: \n");
printf("\nEnter the value of x1 and y1: \t");
scanf("%d %d", &x1, &y1);
printf("\nEnter Final Line Coordinates: \n");
printf("\nEnter the value of x2 and y2: \t");
scanf("%d %d", &x2, &y2);
dx=abs(x2-x1);
dy=abs(y2-y1);
if(dx>=dy) {
inc =dx;
}
else {
inc =dy;
}
dx = dx/inc;
dy = dy/inc;
x = x1;
y = y1;
for(count = 1; count <= inc; count++) {
putpixel(x, y, 4);
x = x + dx;
y = y + dy;
}
getch();
closegraph();
return 0;
}
Subhadip Mandal