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. scanf("%d %d %d %d", &a, &b, &c, &d);
  10.  
  11. // max関数を入れ子にして、4つの最大値求める
  12. int result = max(max(a, b), max(c, d));
  13. printf("最大値 %d \n", result);
  14.  
  15. return 0;
  16. }
  17.  
  18. //max関数の定義
  19. int max(int x, int y){
  20. if(x > y){
  21. return x;
  22. } else {
  23. return y;
  24. }
  25. }
  26.  
  27.  
Success #stdin #stdout 0s 5304KB
stdin
2
5
7
9
stdout
最大値 9