#include<iostream>

using namespace std;

static int Dk,DeltaX,DeltaY,Xk,Yk;

void Berzenham_Lines_Algorithm(int x1,int y1,int x2,int y2)
{
	
	DeltaX=x2-x1;
	DeltaY=y2-y1;
	Xk=x1;
	Yk=y1;
	Dk=2*(DeltaY)-DeltaX;
	cout<<"Xk Yk Dk\n";
	for(int i=1; Xk<x2, Yk<y2; i++)
	{
		cout<<Xk<<" "<<Yk<<" "<<Dk<<"\n";
		if(Dk>0)  //Select NE
		{
			Xk+=1;
			Yk+=1;
			Dk=Dk+2*(DeltaY-DeltaX);
		}
		else  if(Dk<=0)  //Select E
		{
			Xk+=1;
			Dk=Dk+2*DeltaY;
		}
		else 
		break;
	}
}

int main( )
{
	cout<<"Enter two vertex of line for show you berzenham algorithm \nEnter like  (x1,y1) , (x2,2)   :\n\n";
	int X1,X2,Y1,Y2;
	cout<<"Enter x1:  ";
	cin>>X1;
	cout<<"\nEnter y1:  ";
	cin>>Y1;
	cout<<"\nEnter x2:  ";
	cin>>X2;
	cout<<"\nEnter y2:  ";
	cin>>Y2;
	Berzenham_Lines_Algorithm(X1,Y1,X2,Y2);

	return 0;
}