Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <iomanip>
- #include <cmath>
- using namespace std;
- int main() {
- int x1,x2,y1,y2,a,b,c,tg,x,y,k,n,i;
- cin >> x1 >> y1 >> x2 >> y2;
- x=abs(x2-x1);
- y=abs(y2-y1);
- tg=y/x;
- n=0;
- k=0;
- if (x1==x2)
- {
- n=abs(y2-y1);
- }
- if (y1==y2)
- {
- n=abs(x2-x1);
- }
- while (x1<x2)
- {
- k++;
- x1++;
- y=tg*k;
- i=abs(y);
- if (y=i)
- n++;
- }
- while (x1>x2)
- {
- k++;
- x2++;
- y=tg*k;
- i=int(y);
- if (y=i)
- n++;
- }
- n=n+1;
- cout <<n;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement