Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- void rec(int n, int prev, int *a) {
- int i;
- if (n == 0) {
- *a += 1;
- } else {
- for (i = 1; i <= n; i++)
- if (i >= prev)
- rec(n - i, i, a);
- }
- }
- int main() {
- int n, c = 0;
- int *a = &c;
- scanf("%d", &n);
- rec(n, 0, a);
- printf("%d", *a - 1);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement