// 16x2.cpp : Defines the entry point for the console application.//#include "stdafx.h"// 优化了回溯代码// 即不移动到不可能包含比当前最优解还要好的解的右子树#include<iostream.h>template<class T>class Loading { friend GetMaxLoading(T [], T, int); private: void Compute(int i); int n; // 货箱数量 T *w, // 货箱重量数组... Read More
posted @ 2012-02-10 03:43 findumars Views(1759) Comments(0) Diggs(0) Edit
// 16x1.cpp : Defines the entry point for the console application.//#include "stdafx.h"// 回溯法,解空间分为排列数和子集树,前者是不同节点顺序的排列,后者是一个(0,1,...)的向量子集// 最大装载问题,是一个NP问题,目前只计算第一艘船,属于子集树// 有几个货物,子集树就有几层,当前题目为5层// 我感觉递归还是太过于精巧和经凑,很难挖空心思自己写出来,多熟悉别人现有的程序是一个好办法。#include<iostream.h>template<class T& Read More
posted @ 2012-02-10 03:40 findumars Views(3756) Comments(0) Diggs(0) Edit
// 15x2.cpp : Defines the entry point for the console application.//#include "stdafx.h"#include <iostream.h>#include <stdlib.h>#include "dosmax.h" // has max() and min()#include "make2db.h" // void Make2DArray(T ** &x, int rows, int cols)// 动态规划:0-1背包问题( Read More
posted @ 2012-01-28 18:37 findumars Views(1751) Comments(0) Diggs(0) Edit
// 最优原则:不管前面的策略如何,此后的决策是是基于当前状态(由上一次决策产生)的最优决策。// 当最优决策序列中包含最优决策子序列时,可建立动态规划递归方法。// (有些问题的递归式不一定能保证最优原则,因此在求解时有必要对它进行验证。若不能保持最优原则,则不可应用动态规划方法。)// 在得到最 Read More
posted @ 2012-01-28 18:35 findumars Views(5316) Comments(0) Diggs(0) Edit
我感觉,掌握Windows编程需要掌握三样东西:WinAPI —— 这是基础,也是利用Windows特殊功能的强大武器。相当于了VCL的属性+方法(OS的内部数据不能直接操作,全部要通过WinAPI操作)。Message —— 这是Windows的运行机制。相当于VCL的事件,碰到什么消息,就进行相 Read More
posted @ 2012-01-28 17:45 findumars Views(952) Comments(0) Diggs(0) Edit