2013年3月6日

摘要: 闲来无事,跑到POJ上找找水题,好久不写C的代码,感觉生疏了。View Code 1 #include<stdio.h> 2 #include<string.h> 3 #define MAXN 19 4 int num[MAXN]; 5 6 void OutputBinaryTree(int n, int k, bool s) { 7 if (n == 0) return; 8 int i, j, sum; 9 for (i = sum = 0, j=num[n-1]; sum + j < k; sum += j, ++i, j = num[i] * num[n- 阅读全文
posted @ 2013-03-06 23:05 ltang 阅读(235) 评论(0) 推荐(0) 编辑

2011年8月17日

摘要: 简介试程序有很多方法,例如向屏幕上打印消息,使用调试器,或者只需仔细考虑程序如何运行,并对问题进行有根有据的猜测。在修复 bug 之前,首先要确定在源程序中的位置。例如,当一个程序产生崩溃或生成核心转储(core dump)时,您就需要了解是哪行代码发生了崩溃。在找到有问题的代码行之后,就可以确定这个函数中变量的值,函数是如何调用的,更具体点说,为什么会发生这种错误。使用调试器查找这些信息非常简单。本文将简要介绍几种用于修复一些很难通过可视化地检查代码而发现的 bug 的技术,并阐述了如何使用在 Linux on Power 架构上可用的工具。回页首调试内存问题的工具和技术动态内存分配看起来似 阅读全文
posted @ 2011-08-17 23:34 ltang 阅读(484) 评论(0) 推荐(0) 编辑

2011年7月31日

摘要: Python 自1.5版本起增加了re 模块,它提供 Perl 风格的正则表达式模式。Python 1.5之前版本则是通过 regex 模块提供 Emecs 风格的模式。Emacs 风格模式可读性稍差些,而且功能也不强,因此编写新代码时尽量不要再使用 regex 模块,当然偶尔你还是可能在老代码里发现其踪影。 就其本质而言,正则表达式(或 RE)是一种小型的、高度专业化的编程语言,(在Python中)它内嵌在Python中,并通过 re 模块实现。使用这个小型语言,你可以为想要匹配的相应字符串集指定规则;该字符串集可能包含英文语句、e-mail地址、TeX命令或任何你想搞定的东西。然後你可以. 阅读全文
posted @ 2011-07-31 19:35 ltang 阅读(3860) 评论(0) 推荐(1) 编辑

2011年5月7日

摘要: 预流推进算法2(relable-front)算法,时间复杂度O(v^3) 1 // The relable-front algorithm code due to CLRS chapter 26 2 #include<iostream> 3 #include<list> 4 using namespace std; 5 const int N = 100; 6 int n; // vertex number 7 int e[N]; // residual flow of the vertex 8 int h[N]; // height of the vertex 9 i 阅读全文
posted @ 2011-05-07 16:11 ltang 阅读(672) 评论(0) 推荐(0) 编辑
摘要: 预流推进算法(push-relable),时间复杂度O(V^2E) 1 // The push-relable algorithm code due to CLRS chapter 26 2 #include<iostream> 3 #include<list> 4 using namespace std; 5 const int N = 100; 6 int n; // vertex number 7 int e[N]; // residual flow of the vertex 8 int h[N]; // height of the vertex 9 int c 阅读全文
posted @ 2011-05-07 12:40 ltang 阅读(1677) 评论(0) 推荐(0) 编辑

导航