Advertisement
Guest User

Untitled

a guest
Jan 26th, 2020
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cmath>
  4. using namespace std;
  5. int main() {
  6. int x1,x2,y1,y2,a,b,c,tg,x,y,k,n,i;
  7. cin >> x1 >> y1 >> x2 >> y2;
  8. x=abs(x2-x1);
  9. y=abs(y2-y1);
  10. tg=y/x;
  11. n=0;
  12. k=0;
  13. if (x1==x2)
  14. {
  15. n=abs(y2-y1);
  16. }
  17. if (y1==y2)
  18. {
  19. n=abs(x2-x1);
  20. }
  21. while (x1<x2)
  22. {
  23. k++;
  24. x1++;
  25. y=tg*k;
  26. i=abs(y);
  27. if (y=i)
  28. n++;
  29. }
  30. while (x1>x2)
  31. {
  32. k++;
  33. x2++;
  34. y=tg*k;
  35. i=int(y);
  36. if (y=i)
  37. n++;
  38. }
  39. n=n+1;
  40. cout <<n;
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement