在n个球中,任意取m个(不放回),求有多少种不同取法:
#include <stdio.h>
int ball(int n, int m) {
if (n < m) return 0;
if (n == m) return 1;
if (m == 0) return 1;
return ball(n - 1, m - 1) + ball(n - 1, m);
}
void main() {
int n, m;
scanf("%d%d", &n, &m);
printf("%d", ball(n, m));
}
![](http://tiebapic.baidu.com/forum/w%3D580/sign=e23ee09a9d13632715edc23ba18ea056/b5f3c408c93d70cfc826d64befdcd100b8a12be3.jpg?tbpicau=2024-09-19-05_788c52a85353f55dc19c9740619f85ea)
#include <stdio.h>
int ball(int n, int m) {
if (n < m) return 0;
if (n == m) return 1;
if (m == 0) return 1;
return ball(n - 1, m - 1) + ball(n - 1, m);
}
void main() {
int n, m;
scanf("%d%d", &n, &m);
printf("%d", ball(n, m));
}
![](http://tiebapic.baidu.com/forum/w%3D580/sign=e23ee09a9d13632715edc23ba18ea056/b5f3c408c93d70cfc826d64befdcd100b8a12be3.jpg?tbpicau=2024-09-19-05_788c52a85353f55dc19c9740619f85ea)