Oh come on. You can do DDA. Even I needed only 2 minutes of study. This is the result:
Code:
#include <iostream>
using namespace std;
void DDA(int x1,int y1,int x2, int y2)
{
int length;
double x,y;
double xIncr, yIncr;
length = abs(x2 - x1);
if (abs(y2 - y1) > length)
{
length = abs(y2 - y1);
}
xIncr = (double)(x2 - x1)/(double)length;
yIncr = (double)(y2 - y1)/(double)length;
x = x1 + 0.5;
y = y1 + 0.5;
while(length)
{
cout<<(int)x<<", "<<(int)y<<endl;
x += xIncr;
y += yIncr;
--length;
}
}
int main(int argc, char *argv[])
{
DDA(-5, -3, 5, 9);
cin.get();
return 0;
}