- 利用分治算法求解一个序列的最大子序列
分治算法有三步(第三步忘记了,明天补充): 分解: 合并:
还有好多语法不会,明天再写吧
#include <iostream>
using namespace std;
class CSuanFa
{
public:
double FatherList[9];
int GetMaxSubList(double FatherList[9]);
int GetCrossMaxSub(double FatherList[9], int LeftIdx, int RightIdx);
};
int CSuanFa::GetMaxSubList(double FatherList[9])
{
cout << FatherList << endl;
return 1;
}
int main()
{
double FatherList[9] = {1, 4, -3, 7, -9, 4, 8, 1, -7};
CSuanFa oSuanfa;
int result;
result = oSuanfa.GetMaxSubList(FatherList);
cout << "The result is:" << result << endl;
}
|