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