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