fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3. #define max(a,b) (a)>(b)?(a):(b)
  4.  
  5. int main()
  6. {
  7. double a, b, c, t;
  8.  
  9. printf("a b c = ");
  10. scanf("%lf %lf %lf", &a, &b, &c);
  11.  
  12. printf("最大の直線距離 = %f\n", sqrt(a * a + b * b + c * c));
  13.  
  14. t = max(max(a, b), c);
  15. t = (a + b + c - t) * (a + b + c - t) + t * t;
  16. t = sqrt(t);
  17. printf("表面上を移動したときの最小距離 = %f\n", t);
  18.  
  19. return 0;
  20. }
Success #stdin #stdout 0.01s 1724KB
stdin
1
2
3
stdout
a b c  = 最大の直線距離 = 3.741657
表面上を移動したときの最小距離 = 4.242641