集合划分问题
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); }