Advertisement
Guest User

pointdist.c

a guest
Mar 21st, 2018
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.39 KB | None | 0 0
  1. #include <math.h>
  2. #include <stdio.h>
  3.  
  4. struct Point
  5. {
  6.     int x;
  7.     int y;
  8. };
  9.  
  10. double dist(struct Point *a, struct Point *b)
  11. {
  12.     return sqrt(pow(a->x - b->x, 2) + pow(a->y - b->y, 2));
  13. }
  14.  
  15. int main()
  16. {
  17.     struct Point p1;
  18.     struct Point p2;
  19.     p1.x = 1;
  20.     p1.y = 0;
  21.     p2.x = 0;
  22.     p2.y = 1;
  23.     printf("Distance between points [%d, %d] and [%d, %d] is %f\n", p1.x, p1.y,
  24.            p2.x, p2.y, dist(&p1, &p2));
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement