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