Created
October 24, 2022 08:46
-
-
Save emasaka/16f07919aac2b615bd2c275db98a5d5d to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int _add(int a, int b){ return a+b; } | |
int _sub(int a, int b){ return a-b; } | |
int _mul(int a, int b){ return a*b; } | |
int _div(int a, int b){ return a/b; } | |
struct { char c; int (*f)(int, int); } ops[] = | |
{ {'+', _add}, {'-', _sub}, {'*', _mul}, {'/', _div}}; | |
int main() | |
{ | |
for(int i0 =0; i0 < 4; i0++) { | |
for(int i1 =0; i1 < 4; i1++) { | |
for(int i2 =0; i2 < 4; i2++) { | |
for(int i3 =0; i3 < 4; i3++) { | |
printf("6%c4%c5%c2%c1=", ops[i0].c, ops[i1].c, ops[i2].c, ops[i3].c); | |
printf("%d\n", ops[i3].f(ops[i2].f(ops[i1].f(ops[i0].f(6, 4), 5), 2), 1)); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment