fork download
  1. #include <stdio.h>
  2. #include <math.h>
  3. #include <assert.h>
  4.  
  5. // Define the lambda functions as regular C functions
  6. int f(int a, int b) {
  7. return ((b - a + 0.1) / (b - a + 0.2));
  8. }
  9.  
  10. int mx(int a, int b) {
  11. return f(a, b) * a + f(b, a) * b + a * (1 - f(a, b) - f(b, a));
  12. }
  13.  
  14. int main() {
  15. for (int i = -10; i < 10; i++) {
  16. for (int j = -10; j < 10; j++) {
  17. int t1 = mx(i, j);
  18. int t2 = i > j ? i : j;
  19. assert(t1 == t2);
  20. // Uncomment the line below to print f(i, j) values
  21. // printf("f(%d, %d) = %f\n", i, j, f(i, j));
  22. }
  23. }
  24. printf("All assertions passed.\n");
  25. return 0;
  26. }
  27.  
Success #stdin #stdout 0s 5280KB
stdin
Standard input is empty
stdout
All assertions passed.