Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- void midPoint(int X1, int Y1, int X2, int Y2)
- {
- int dx = X2 - X1;
- int dy = Y2 - Y1;
- int a = dy;
- int b = -dx;
- int d = 2*a + b;
- int i = X1, j = Y1;
- cout <<"The Value of (x,y) = "<<"(" << i << "," << j <<")"<< "\n";
- while (i < X2)
- {
- i++;
- if (d <= 0)
- d = d + 2*a ;
- else
- {
- d += 2*(a + b);
- j++;
- }
- cout <<"The Value of (x,y) = "<<"("<< i << "," << j <<")" << "\n";
- }
- }
- int main()
- {
- int X1, Y1, X2, Y2;
- cout<<"Enter the Value of X1: ";
- cin>>X1;
- cout<<"Enter the Value of Y1: ";
- cin>>Y1;
- cout<<"Enter the Value of X2: ";
- cin>>X2;
- cout<<"Enter the Value of Y2: ";
- cin>>Y2;
- midPoint(X1, Y1, X2, Y2);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement