Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- unsigned char x[16] = { 1, 1, 1, 1, 1, 1,
- 2, 2, 2, 2, 2,
- 3, 3, 3, 3, 3};
- unsigned int sum = 0;
- unsigned int a = 0, b = 0;
- void rec(unsigned int i, unsigned int count) {
- if (count == 3) {
- if (sum == 6) a++;
- b++;
- return;
- }
- for (; i < 16; i++) {
- sum += x[i];
- rec(i+1, count+1);
- sum -= x[i];
- }
- }
- int main() {
- rec(0, 0);
- printf("%d/%d=%f\n", a, b, (float) a/b);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement