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. double max(double x, double y){
  16. return (x>y)?x:y;
  17. }
  18.  
  19. //引数の絶対値を返す関数
  20. double abs(double x){
  21. return (x>0)?x:-x;
  22. }
  23.  
  24. //引数の三乗の値を返す関数
  25. double cube(double x){
  26. return x*x*x;
  27. }
  28.  
  29.  
  30.  
  31.  
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
max(|-3.200000|,(1.400000)^3)=3.200000