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