Advertisement
Guest User

Untitled

a guest
Sep 21st, 2017
45
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.48 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. #define sqr(a) ((a)*(a))
  5. typedef long double ld;
  6.  
  7.  
  8. ld d(ld x, ld y, ld a, ld b, ld c)
  9. {
  10. return (abs(a*x + b*y + c) / sqrt(a*a + b*b));
  11. }
  12.  
  13.  
  14.  
  15. int main()
  16.  
  17. {
  18. ifstream cin("input.txt");
  19.  
  20. int x, y, x1, y1, x2, y2;
  21. long double a, b, c;
  22.  
  23. cin >> x >> y >> x1 >> y1 >> x2 >> y2;
  24.  
  25. a = (y2 - y1);
  26. b = (x1 - x2);
  27. c = (x2*y1 - x1*y2);
  28.  
  29. cout << fixed << setprecision(60) << abs(d(x, y, a, b, c)) << endl;
  30.  
  31. return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement