C算法 集合划分问题
1 问题描述:
2 数学建模:
2.1思路分析
2.2 数学公式
3 算法实现
#include <stdio.h>
#include <stdlib.h>
int gatherRecursion(int n, int m)
{
if (m==1||m == n)
{
return 1;
}else {
return m * gatherRecursion(n - 1, m) + gatherRecursion(n - 1, m - 1);
}
}
int main()
{
int gatherElement = 5;
int sum = 0;
for (int i = 1; i <= gatherElement; i++)
{
int result = gatherRecursion(gatherElement, i);
sum=sum+result;
printf("gahterNum(%d,%d)=%d\n", gatherElement,i,result);
}
printf("集合%d的所有划分数为:%d\n", gatherElement, sum);
return 0;
}