fork download
  1. #include <math.h>
  2. #include <stdio.h>
  3.  
  4. struct point
  5. {
  6. double x;
  7. double y;
  8. };
  9.  
  10. typedef struct point Point;
  11.  
  12. double Distance (Point * p);
  13. double Distance2 (Point * p1,Point * p2);
  14.  
  15.  
  16. double Distance2 (Point *p1,Point *p2){
  17. return sqrt( pow((p1->x)+(p2->x),2) + pow((p1->y)+(p2->y),2));
  18. }
  19.  
  20. double Distance (Point *p1){
  21. return sqrt( pow((p1->x),2) + pow((p1->y),2));
  22. }
  23.  
  24. void main(int argc, char* argv[])
  25. {
  26. double x1,x2,y1,y2;
  27. scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
  28.  
  29. Point a;
  30. a.x = x1;
  31. a.y = y1;
  32.  
  33. Point b;
  34. b.x = x2;
  35. b.y = y2;
  36.  
  37. printf ("%lf",Distance2(&a,&b));
  38. }
Success #stdin #stdout 0s 5328KB
stdin
Standard input is empty
stdout
0.000000