摘要: 参考维基百科http://en.wikipedia.org/wiki/Maze_generation_algorithm1 深度优先搜索Start at a particular cell and call it the "exit."Mark the current cell as visited, and get a list of its neighbors. For each neighbor, starting with a randomly selected neighbor:If that neighbor hasn't been visited, r 阅读全文
posted @ 2012-04-11 23:24 visayafan 阅读(3812) 评论(0) 推荐(2) 编辑
摘要: Prim 算法思想:从任意一顶点 v0 开始选择其最近顶点 v1 构成树 T1,再连接与 T1 最近顶点 v2 构成树 T2, 如此重复直到所有顶点均在所构成树中为止。Prim 算法步骤:T0 存放生成树的边,初值为空输入加权图的带权邻接矩阵 C = (Cij)n×n (两点间无边相连则其大小为无穷)为每个顶点 v 添加一属性 L(v) :表 v 到 T0 的最小直接距离1) T0←∅, V1={v0}, C(T0)=02) 对任意v ∈ V,L(v)←C(v, v0)3) If V==V1 then stop else goto next.4) 在 V-V1 中找点 u 使 L(u 阅读全文
posted @ 2012-04-11 23:02 visayafan 阅读(5532) 评论(0) 推荐(0) 编辑
摘要: 官方文档:http://gcc.gnu.org/onlinedocs/gcc/Designated-Inits.htmlC99标准引入了Designated Initializers特性使得数组、结构体和联合体的初始化更加灵活和方便。对于一个数组:int a[10] = { [1] = 1, [8 ... 9] = 10 };这样可以只初始化a[1], a[8], a[9]三个元素,其他元素的值为0,相当于:int a[10] = {0, 1, 0, 0, 0, 0, 0, 0, 10, 10};对于一个结构体:struct point { int x, y;};struct point p 阅读全文
posted @ 2012-04-11 11:54 visayafan 阅读(636) 评论(0) 推荐(0) 编辑