摘要: 本质和最长有序子序列一样 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include #include typedef struct _mouse { int size; int speed; int id;}Mouse;M... 阅读全文
posted @ 2009-04-15 21:20 断桥残雪 阅读(135) 评论(0) 推荐(0)
摘要: 我觉得算不得完全意义的动态规划 求直线交点,把直线分2组,和第N条平行(N-M条)、不平行(M条)(0#include #include int res[21][200];void add(int i, int val){ int j; int r; for (j = 1; j val) break; } if (j > res[i][0]) { re... 阅读全文
posted @ 2009-04-15 09:43 断桥残雪 阅读(161) 评论(0) 推荐(0)
摘要: 看题不仔细,没考虑所有数字都可能小于0的情况,都被DS书上的例子给影响了。 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include #include #include int res[110000];int main(){ int ... 阅读全文
posted @ 2009-04-14 20:21 断桥残雪 阅读(91) 评论(0) 推荐(0)
摘要: 简单计算题 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include #include using namespace std;int main(){ double len; while (cin >> len) { ... 阅读全文
posted @ 2009-04-11 12:32 断桥残雪 阅读(92) 评论(0) 推荐(0)
摘要: 此题主要是字符串转换 + 哈希表 Code highlighting produced by Actipro CodeHighlighter (freeware)http://www.CodeHighlighter.com/-->#include #include #include #define HASH_MAX 100000typedef struct _node { int key... 阅读全文
posted @ 2009-04-11 11:30 断桥残雪 阅读(193) 评论(0) 推荐(0)
摘要: 设计原则:类应该对扩展开放,对修改关闭 装饰者模式 装饰者和被装饰对象有相同的超类型,所以在任何需要原始对象的场合,可以用装饰过的对象替代它 你可以用一个或多个装饰者包装一个对象,加上自己的行为,达到特定的目的 对象可以在任何时候被装饰,达到运行时动态 阅读全文
posted @ 2009-03-28 13:45 断桥残雪 阅读(82) 评论(0) 推荐(0)
摘要: Observer在java里用的很多,比如常见的监听器,用处类似就不多说了 Java内置了类Observerable和接口Observer 阅读全文
posted @ 2009-03-28 13:31 断桥残雪 阅读(94) 评论(0) 推荐(0)
摘要: 看完head first第一章,深深被设计模式所吸引,觉得很新鲜,忍不住想要在此记录自己的体会。 区分变与不变,变即算法,不变嘛,我理解为状态,或者为特征。 多用聚合,少用继承,从而带来更大的灵活性和易维护性。对象只需关注自身特征的维护,而把算法交给外部来处理。 阅读全文
posted @ 2009-03-28 12:44 断桥残雪 阅读(89) 评论(0) 推荐(0)
摘要: 此题思想:枚举每个硬币是light or heavy,依次验证三个结果是否一致 Code highlighting produced by Actipro CodeHighlighter (freeware) http://www.CodeHighlighter.com/ -->#include #include #include using namespace std; vect... 阅读全文
posted @ 2009-03-21 13:16 断桥残雪 阅读(186) 评论(0) 推荐(0)
摘要: Adapter模式 Adapter模式允许我们使用现有类来满足客户类的需求。当客户指定接口中的需求时,我们通常可以创建一个新类来实现接口和扩展现有类。这种方法会创建一个类适配器,它将客户的调用转变为调用现有类的方法。 当客户没有指定所需要的接口时,我们仍然可以应用Adapter模式,并使用现有类的实例来创建一个新的客户子类。这种方法会创建一个对象适配器,将客户调用转发给现有类的实例。但是这... 阅读全文
posted @ 2009-03-12 13:24 断桥残雪 阅读(142) 评论(1) 推荐(0)