fork download
  1. #include<iostream>
  2. #include<graphics.h>
  3. #include<cmath>
  4. using namespace std;
  5. void DDA(int X0, int Y0, int X1, int Y1)
  6. {
  7. int dx = X1 - X0;
  8. int dy = Y1 - Y0;
  9. int steps = abs(dx) > abs(dy) ? abs(dx) : abs(dy);
  10. float Xinc = dx / (float) steps;
  11. float Yinc = dy / (float) steps;
  12. float X = X0;
  13. float Y = Y0;
  14. for (int i = 0; i <= steps; i++)
  15. {
  16. putpixel (X,Y,RED); // put pixel at (X,Y)
  17. X += Xinc; // increment in x at each step
  18. Y += Yinc; // increment in y at each step
  19. delay(100); // for visualization of line-
  20. // generation step by step
  21. }
  22. }
  23. int main()
  24. {
  25. int gd = DETECT, gm;
  26. initgraph (&gd, &gm, "");
  27. int X0 = 2, Y0 = 2, X1 = 14, Y1 = 16;
  28. DDA(2, 2, 14, 16);
  29. return 0;
  30. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:2:9: fatal error: graphics.h: No such file or directory
 #include<graphics.h>
         ^~~~~~~~~~~~
compilation terminated.
stdout
Standard output is empty