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