fork download
  1. #include <stdio.h>
  2.  
  3. double max(double,double);
  4. double abs(double);
  5. double cube(double);
  6.  
  7. //main関数
  8. int main(void) {
  9. double a, b;
  10. a = -3.2;
  11. b = 1.4;
  12. printf("max(|%f|,(%f)^3)=%f\n",a,b,max(abs(a),cube(b)));
  13. return 0;
  14. }
  15.  
  16. //二つの引数の大きい方の値を返す関数
  17. double max(double x, double y){
  18. return (x>y)?x:y;
  19. }
  20.  
  21. //引数の絶対値を返す関数
  22. double abs(double x){
  23. return (x>0)?x:-x;
  24. }
  25.  
  26. //引数の三乗の値を返す関数
  27. double cube(double x){
  28. return x*x*x;
  29. }
  30.  
  31.  
Success #stdin #stdout 0s 5264KB
stdin
Standard input is empty
stdout
max(|-3.200000|,(1.400000)^3)=3.200000