Advertisement
Guest User

Untitled

a guest
Nov 18th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.34 KB | None | 0 0
  1. #include <stdio.h>
  2.  
  3. void rec(int n, int prev, int *a) {
  4.     int i;
  5.     if (n == 0) {
  6.         *a += 1;
  7.     } else {
  8.         for (i = 1; i <= n; i++)
  9.             if (i >= prev)
  10.                 rec(n - i, i, a);
  11.     }
  12. }
  13.  
  14. int main() {
  15.     int n, c = 0;
  16.     int *a = &c;
  17.     scanf("%d", &n);
  18.     rec(n, 0, a);
  19.     printf("%d", *a - 1);
  20. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement