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