Guest User

100168 G

a guest
Jan 28th, 2021
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.47 KB | None | 0 0
  1. #include <cstdio>
  2. #include <cmath>
  3.  
  4. #define FILE_NAME "distance2"
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. #ifdef ONLINE_JUDGE
  11.     freopen(FILE_NAME".in", "r", stdin);
  12.     freopen(FILE_NAME".out", "w", stdout);
  13. #endif
  14.  
  15.     double x, y, x1, y1, x2, y2;
  16.     scanf("%lf%lf%lf%lf%lf%lf", &x, &y, &x1, &y1, &x2, &y2);
  17.  
  18.     double a = y1 - y2, b = x2 - x1, c = x1 * y2 - y1 * x2;
  19.     double k = abs((a * x + b * y + c) / sqrt(a * a + b * b));
  20.  
  21.     printf("%.12lf\n", k);
  22.  
  23.     return 0;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment