fork download
  1. #include <stdio.h>
  2.  
  3. int nearest(int x)
  4. {
  5. #define decide(a, b) if (x <= (a + b) / 2) return a
  6.  
  7. decide( 98, 100);
  8. decide(100, 198);
  9. decide(198, 200);
  10. decide(200, 250);
  11. decide(250, 298);
  12. return 298;
  13.  
  14. #undef decide
  15. }
  16.  
  17. int main(void)
  18. {
  19. printf("%d -> %d\n", 50, nearest(50));
  20. printf("%d -> %d\n", 195, nearest(195));
  21.  
  22. return 0;
  23. }
Success #stdin #stdout 0s 4476KB
stdin
Standard input is empty
stdout
50 -> 98
195 -> 198