您的位置:首页 > 其它

集合划分问题

2016-12-24 14:37 239 查看
#include <stdio.h>

int count(int n, int m) {
if ((m > n ) || (m == 0))
return 0;
if ((m == 1 ) || (m == n))
return 1;
return count(n-1, m-1) + m*count(n-1, m); //根据公式求解
}

int main() {
int result = 0;
int n;
scanf("%d", &n);
int i; //考虑到vc++,不能在for()里面定义int i, zhenshidanteng
for (i = 1; i <= n;i++) {
result += count(n, i);
}
printf("%d" , result);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: