fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3. struct coordinate{
  4. double x;
  5. double y;
  6. double z;
  7. }A={1,5,2},B={5,3,1},C={2,8,4};
  8. int main(void) {
  9. double d = sqrt((B.x-A.x)*(B.x-A.x)+(B.y-A.y)*(B.y-A.y)+(B.z-A.z)*(B.z-A.z));
  10. double e = sqrt((C.x)*(C.x)+(C.y)*(C.y)+(C.z)*(C.z));
  11. printf("%f\n",d);
  12. printf("%f\n",e);
  13. return 0;
  14. }
  15.  
Success #stdin #stdout 0.01s 5324KB
stdin
Standard input is empty
stdout
4.582576
9.165151