Advertisement
IlidanBabyRage

278.cpp

Jul 19th, 2015
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <cstdio>
  4.  
  5. using namespace std;
  6.  
  7. double getS(double ax, double ay, double bx, double by);
  8.  
  9. int main(){
  10.    
  11.     double cx, cy, ax, ay, bx, by;
  12.     cin >> cx >> cy >> ax >> ay >> bx >> by;
  13.     bx -= ax;
  14.     cx -= ax;
  15.     by -= ay;
  16.     cy -= ay;
  17.  
  18.     if (bx * cx + by * cy >= 0)
  19.         cout << abs(getS(bx, by, cx, cy)) / sqrt(bx * bx + by * by);
  20.     else
  21.         cout << sqrt(cx * cx + cy * cy) << endl;
  22.  
  23.     return 0;
  24. }
  25.  
  26. double getS(double ax, double ay, double bx, double by){
  27.     return (bx * ay - ax * by);
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement