整数划分算法

#include
using namespace std;
int cuo(int n){
	int *pc = (int *)malloc(sizeof(int)*n);
	for (int i = 0; i <= n; i++)
		pc[i] = 0;
	pc[1] = 1;
	pc[2] = 2; 
	for (int i = 3; i <= n;i++)
	if (i % 2 != 0) pc[i] = pc[i - 1];//n为奇数
	else pc[i] = pc[i - 1] + pc[i / 2];//n为偶数
	for (int i = n; i <= n; i++)
		return pc[i];
}
int main()
{
	int n;
	cout << "输入数" << endl;
	cin >> n;
	cout << "划分总数为" << endl;
	cout<

你可能感兴趣的:(算法,c++,数据结构)