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