#include #include "output.h" void line(int x0, int y0, int x1, int y1) { int x = x0; int y = y0; int a = x1 - x0; int b = y1 - y0; int d = 0; /* d = a * (y-y0) - b * (x-x0)*/ /* Check preconditions */ assert(a >= 0); assert(b >= 0); assert(b <= a); /* End of check of preconditions */ output(x, y); while(x < x1) { x += 1; d -= b; if(2*d < -a) { y += 1; d += a; } output(x, y); } }