Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- // Combination
- int f(int n, int r);
- int main(void){
- int n, m;
- printf("組合せの数nCrを入力");
- scanf("%d%d", &n, &m);
- printf("%d\n", f(n, m));
- }
- int f(int n, int r){
- if( r == n )
- return 1;
- else if ( r == 1)
- return n;
- else
- return f(n -1, r -1) + f(n-1, r);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement