kolioi

51. Distance C++

Jan 5th, 2019
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.35 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. typedef struct
  7. {
  8.     double x;
  9.     double y;
  10. } Point;
  11.  
  12. double distance(const Point& a, const Point& b)
  13. {
  14.     return sqrt((a.x - b.x)*(a.x - b.x) + (a.y - b.y)*(a.y - b.y));
  15. }
  16.  
  17. int main()
  18. {
  19.     Point a, b;
  20.  
  21.     cin >> a.x >> a.y >> b.x >> b.y;
  22.  
  23.     cout << distance(a, b) << endl;
  24.  
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment