fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. struct condidate{
  5. double x;
  6. double y;
  7. double z;
  8. };
  9.  
  10. int main(void) {
  11. struct condidate a = {1, 5, 2};
  12. struct condidate b = {5, 3, 1};
  13. struct condidate c = {2, 8, 4};
  14.  
  15. double length_ab;
  16. double length_oc;
  17.  
  18. length_ab = 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));
  19. length_oc = sqrt((c.x * c.x + c.y * c.y + c.z * c.z));
  20.  
  21. if(length_ab>length_oc)
  22. printf("length_ab: %lf",length_ab);
  23. else printf("length_oc: %lf\n",length_oc);
  24.  
  25. return 0;
  26. }
  27.  
Success #stdin #stdout 0.01s 5324KB
stdin
Standard input is empty
stdout
length_oc: 9.165151