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