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関数の入れ子で最大値を求める
  12. int m1,m2,m3;
  13.  
  14. m1 = max(a,b);
  15. m2 = max(c,d);
  16. m3 = max(m1,m2);
  17.  
  18. printf("最大値 = %d\n",m3);
  19.  
  20. return 0;
  21. }
  22.  
  23. //max関数の定義
  24. int max(int x, int y){
  25. return (x > y) ? x : y;
  26. }
Success #stdin #stdout 0s 5288KB
stdin
1
3
5
7
stdout
最大値 = 7