fork download
  1. #include <stdio.h>
  2. //関数のプロトタイプ宣言
  3. //ここ↓を埋めてね1
  4. int max(int x, int y);
  5. //main関数
  6. int main(void) {
  7. int a,b,c,d;
  8. //ここ↓を埋めてね2
  9. a = 1;
  10. b = 5;
  11. c = 3;
  12. d = 4;
  13. int result = max(max(a, b), max(c, d));
  14. printf("4つの数 %d, %d, %d, %d の最大値は: %d\n", a, b, c, d, result);
  15. return 0;
  16. }
  17.  
  18. //max関数の定義
  19. int max(int x, int y){
  20. //ここ↓を埋めてね3
  21. if (x > y) {
  22. return x;
  23. } else {
  24. return y;
  25. }
  26. }
  27.  
  28.  
  29.  
Success #stdin #stdout 0s 5276KB
stdin
Standard input is empty
stdout
4つの数 1, 5, 3, 4 の最大値は: 5