上一页 1 ··· 4 5 6 7 8 9 10 11 下一页

2012年7月25日

Dijkstra算法

摘要: 1 #include <iostream> 2 #include <cstdlib> 3 #include <cstring> 4 #include <map> 5 using namespace std; 6 /*==================================================*\ 7 | Dijkstra 数组实现O (N^2 ) 8 | Dijkstra --- 数组实现( 在此基础上可直接改为STL 的Queue实现) 9 | lowcost[] --- beg 到其他点的最近距离10 | path[] 阅读全文

posted @ 2012-07-25 00:15 kakamilan 阅读(141) 评论(0) 推荐(0) 编辑

2012年7月24日

proxy模式

摘要: 1 #include <iostream> 2 #include <string> 3 #include <vector> 4 #include <queue> 5 #include <set> 6 #include <algorithm> 7 #include <map> 8 #include <stack> 9 using namespace std;10 11 // 女学生类12 // 相当于client类13 class cSchoolGirl {14 private:15 string m 阅读全文

posted @ 2012-07-24 19:43 kakamilan 阅读(247) 评论(0) 推荐(0) 编辑

facade模式

摘要: 有时不想对内部了解太多,只想获得一个接口,facade模式最好不过。 1 #include <iostream> 2 #include <string> 3 #include <vector> 4 #include <queue> 5 #include <set> 6 #include <algorithm> 7 #include <map> 8 #include <stack> 9 using namespace std;10 11 class Subsystem1 {12 public:13 v 阅读全文

posted @ 2012-07-24 16:21 kakamilan 阅读(181) 评论(0) 推荐(0) 编辑

2012年7月23日

拓扑排序

摘要: 看了参加ACM的人写的程序,只能说他们成魔了啊....空间太节省了.... 1 #include <iostream> 2 #include <string> 3 #include <vector> 4 #include <queue> 5 #include <set> 6 #include <algorithm> 7 #include <map> 8 #include <stack> 9 using namespace std; 10 11 void findOrder(int cnt, map& 阅读全文

posted @ 2012-07-23 21:58 kakamilan 阅读(122) 评论(0) 推荐(0) 编辑

flyweight模式

摘要: 1 #include <iostream> 2 #include <map> 3 #include <string> 4 #include <cstring> 5 #include <string.h> 6 #include <cstdlib> 7 using namespace std; 8 9 class Book { 10 public: 11 string GetPublish() { 12 return *m_publishCompany; 13 } 14 string GetWriter() { 15 r... 阅读全文

posted @ 2012-07-23 10:12 kakamilan 阅读(172) 评论(0) 推荐(0) 编辑

2012年7月22日

SRM 550 DIV2

摘要: 还是老样子,悲催,只做出来一个,第二个因为没有考虑一种情况,导致代码写错了第一题就是简单的比较两个字符串中不同的就OK了,最后用数字差模2比较一下就行。第二题以为可以在任意地方拐弯,实际上必须碰到边缘才可以,后来发现的时候没时间改代码了,悲催。思路就是先比较边界的情况,如果合法的话时间上就是在一个矩形中绕圈,判断一下是否合法就OK了。 1 #include <iostream> 2 #include <string> 3 #include <vector> 4 #include <cstdlib> 5 #include <cmath> 阅读全文

posted @ 2012-07-22 14:21 kakamilan 阅读(188) 评论(0) 推荐(0) 编辑

2012年7月21日

composite模式

摘要: 1 #include <iostream> 2 #include <list> 3 using namespace std; 4 //公司类,提供接口,相当于compoent 5 class Company 6 { 7 public: 8 Company(string name) 9 { 10 m_name = name; 11 } 12 13 virtual ~Company() 14 {} 15 16 virtual void Add(Company *pCom) 17 {} 18 19 ... 阅读全文

posted @ 2012-07-21 15:39 kakamilan 阅读(219) 评论(0) 推荐(0) 编辑

2012年7月19日

decorator模式

摘要: 1 #include <iostream> 2 using namespace std; 3 4 class compoent 5 { 6 public: 7 compoent(){} 8 virtual ~compoent(){} 9 10 virtual void Operation(){};11 };12 13 class concretecompoent:public compoent{14 virtual void Operation(){cout<<"I can only do AAAAAAAAAAAAAA!!!!\n";};15 16 阅读全文

posted @ 2012-07-19 16:23 kakamilan 阅读(169) 评论(0) 推荐(0) 编辑

adapter模式

摘要: 1 #include <iostream> 2 using namespace std; 3 4 class target 5 { 6 public: 7 target(){} 8 virtual ~target(){} 9 10 virtual void Operation(){};11 };12 13 class adaptee{14 public:15 void special_work(){16 cout<<"only I can do!!\n";17 }18 };19 20 21 /*类适配器模式22 * 优点:可以重定义... 阅读全文

posted @ 2012-07-19 12:40 kakamilan 阅读(220) 评论(0) 推荐(0) 编辑

bridge模式

摘要: 看了好几天,一直没想明白bridge模式到底怎么用,知道今天把四人帮的书翻出来,看到这样一句话,才恍然大悟,敲出来记录一下。“一般来讲,Implementor接口仅提供基本操作,而Abstraction则定义了基于这些基本操作的较高层次的操作。” 1 #include <iostream> 2 using namespace std; 3 4 5 // 为实现Abstraction定义的抽象基类,定义了实现的接口函数 6 class Implementor 7 { 8 public: 9 Implementor(){}10 virtual ~Implementor(){}1... 阅读全文

posted @ 2012-07-19 10:34 kakamilan 阅读(151) 评论(0) 推荐(0) 编辑

上一页 1 ··· 4 5 6 7 8 9 10 11 下一页

导航