fork download
  1. #include <stdio.h>
  2.  
  3. int max(int x, int y);
  4.  
  5. int main(void) {
  6. int a, b, c, d;
  7.  
  8. a = 1;
  9. b = 4;
  10. c = 3;
  11. d = 2;
  12.  
  13. //4つの数字を2つずつ比較して、最後に大きい方を比較する
  14. printf("最大値は%dです。\n", max(max(a, b), max(c, d)));
  15.  
  16. return 0;
  17. }
  18.  
  19. //(x>y)は真ですか?真ならxを表示、偽ならyを表示
  20. int max(int x, int y) {
  21. return (x > y) ? x : y;
  22. }
  23.  
Success #stdin #stdout 0s 5324KB
stdin
Standard input is empty
stdout
最大値は4です。