Advertisement
Guest User

Exercise_642

a guest
Mar 13th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.41 KB | None | 0 0
  1. // Exercise 6.42 - by Anthony Jett
  2. // Distance Between Points
  3.  
  4. #include <iostream>
  5. #include <cmath>
  6.  
  7. using namespace std;
  8.  
  9. double axisDst(double n1, double n2) {
  10.     return fabs(n2 - n1);
  11. }
  12.  
  13. double distance(double x1, double y1, double x2, double y2) {
  14.     return sqrt((pow(axisDst(x1, x2), 2)) + (pow(axisDst(y1, y2), 2)));
  15. }
  16.  
  17.  
  18. int main()
  19. {
  20.     cout << distance(0,0,3,4) << endl;
  21.     return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement