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