本文将从以下几点浅谈原型模式:
概述
结构图
分类
浅复制:结构图
代码
复制图示
深复制:结构图
代码
复制图示
总结
概述:
用原型实例指定创建对象的种类,并且通过拷贝这些原型创建新的对象。
允许一个对象再创建另外一个可定制的对象,根本无需知道任何如何创建的细节。
复制过程,并不是做一个抽象类,去实例化它。而是只需通过实现一个含有Clone()方法的接口就可以去克隆,这就是.NET在System命名空间中提供的ICloneable接口 。...
分类:
其他好文 时间:
2014-05-05 21:27:41
阅读次数:
359
1,C++中操作数组
#include
using namespace std;
int length(char []);
void output_frequency(char []);
int main()
{
char str[]="yan cong min";
cout<<"要处理的字符串为:"<<str<<endl;
cout<<"字符串长度为:"<<lengt...
分类:
编程语言 时间:
2014-05-05 13:29:30
阅读次数:
432
题目链接:http://poj.org/problem?id=1011
这道题用到了深搜+剪枝。
#include
#include
#include
using namespace std;
int a[65];
int vis[65];
int n;
int cmp(int x,int y)
{
return x>y;
}
int dfs(int len,int need,int ...
分类:
其他好文 时间:
2014-05-05 13:28:57
阅读次数:
290
题目:给定一个n*m大的纸张,上面表明了每块上的字母,在其背后给定了对应位置的字母的value,在最后给出需要剪出来的剪纸的字母序列。
方法:暴力搜索。
代码:
#include
#include
#include
#include
using namespace std;
char map[502][502];
int Map[502][502];
int vis[502][502...
分类:
其他好文 时间:
2014-05-05 12:53:36
阅读次数:
338
LTC男人八题系列,测试数据之强真不是盖的。题目大意是在树上找出所有满足长度 2
#include 3 using namespace std; 4 5 6 #define FOR(p,i,s,t) for(__typeof(p) i=s;
it, Vs[eptr].l = this...
分类:
其他好文 时间:
2014-05-03 22:47:34
阅读次数:
419
题意:给定背包体积与物品的体积与价值 求正好放完的最小价值#includeusing
namespace std;int min(int a,int b){ if(a>t; while(t--) {
cin>>m1>>m2; m=m2-m1; ...
分类:
其他好文 时间:
2014-05-03 22:37:20
阅读次数:
437
在输入密码时,实现有限次密码输入的限制,如果三次都没有输入正确,程序将直接退出,不允许用户继续操作。
#include
#include
using namespace std;
int main()
{
string pwd;
int cLogin=0;
do
{
cout<>pwd;
if (pwd!="123")
{
...
分类:
编程语言 时间:
2014-05-03 17:45:26
阅读次数:
354
题目:经典dp题目,求出最大相邻子序列的和。
方法:给出两种方法,一种dp,一种直接暴力(数据量小的时候可以考虑)。
代码1:
#include
#include
using namespace std;
int main()
{
int n;
int t=1;
cin>>n;
int s[100010];
while(t<=n)
{
...
分类:
其他好文 时间:
2014-05-03 17:02:34
阅读次数:
324
转战单调队列,争取省赛前做完。。。。
这个题是很裸的单调队列。
不能用stl让人很蛋疼。。。。
就是用一个队列保存当前队伍的信息,如果来了一个大的,就把前面的小的挤掉。
#include
#include
#include
#include
#include
#include
using namespace std;
#define maxn 55000
#define INF 99999...
分类:
其他好文 时间:
2014-05-03 16:28:35
阅读次数:
342
本文出自:http://blog.csdn.net/svitter
原题:http://acm.hrbust.edu.cn/index.php?m=ProblemSet&a=showProblem&problem_id=1053
题意:完全背包不解释。。直接贴代码。。
#include
#include
#include
using namespace std;
#defi...
分类:
其他好文 时间:
2014-05-03 16:06:14
阅读次数:
324