摘要: 保证一个类只有一个实例,并提供一个访问它的全局访问点。类图:代码:template<typename T>class Singleton{public: //缺少访问控制 static T* Instance() { if(single==NULL) { single=new T(); } return single; }private: static T* single; Singleton();};template<typename T>T* Singleton<T>::single=NULL;class Graduate{public: void pr 阅读全文
posted @ 2013-06-12 16:34 李VS超 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 问题描述:给定两个序列,找出X和Y的最长公共子序列。子问题的递归结构:代码:#include "stdafx.h"#include<iostream>using namespace std;#define M 7#define N 6char x[M]={'A','B','C','B','D','A','B'};char y[N]={'B','D','C','A','B', 阅读全文
posted @ 2013-06-12 15:16 李VS超 阅读(266) 评论(0) 推荐(0) 编辑
摘要: 问题描述:给定N个整数(可能是负整数)组成的序列,求该序列的最大子段和。该问题的动态规划方程为:b[j]={b[j-1]+a[j],a[j]}代码:#include "stdafx.h"#include<iostream>using namespace std;#define N 6int _tmain(int argc, _TCHAR* argv[]){ cout<<"----------最大子段和---------"<<endl; int data[N]={-2,11,-4,13,-5,-2}; int MaxSu 阅读全文
posted @ 2013-06-12 10:36 李VS超 阅读(1160) 评论(0) 推荐(0) 编辑