Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <cmath>
- #define FILE_NAME "distance2"
- using namespace std;
- int main()
- {
- #ifdef ONLINE_JUDGE
- freopen(FILE_NAME".in", "r", stdin);
- freopen(FILE_NAME".out", "w", stdout);
- #endif
- double x, y, x1, y1, x2, y2;
- scanf("%lf%lf%lf%lf%lf%lf", &x, &y, &x1, &y1, &x2, &y2);
- double a = y1 - y2, b = x2 - x1, c = x1 * y2 - y1 * x2;
- double k = abs((a * x + b * y + c) / sqrt(a * a + b * b));
- printf("%.12lf\n", k);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment