fork download
  1. #include <stdio.h>
  2.  
  3. // プロトタイプ宣言
  4. int max(int x, int y);
  5.  
  6. int main(void) {
  7. int a = 1, b = 5, c = 3, d = 4;
  8. int m;
  9.  
  10. // max関数を入れ子にして最大値を求める
  11. m = max(max(a, b), max(c, d));
  12.  
  13. printf("最大値は %d です。\n", m);
  14.  
  15. return 0;
  16. }
  17.  
  18. // 2つの数の大きい方を返す関数
  19. int max(int x, int y) {
  20. if (x > y)
  21. return x;
  22. else
  23. return y;
  24. }
Success #stdin #stdout 0s 5320KB
stdin
Standard input is empty
stdout
最大値は 5 です。