2013年7月22日

摘要: #include#include#include#include#include#include#include"Test.h"using namespace std;struct Node{ int data; Node *left; Node *right;};int pre[]={1,2,4,7,3,5,6,8};int mid[]={4,7,2,1,5,3,8,6};Node *f(int pre[],int a,int b,int mid[],int m,int n){ if(b-a+1!=n-m+1) throw std::exception(... 阅读全文
posted @ 2013-07-22 22:49 dyc0113 阅读(226) 评论(0) 推荐(0) 编辑
摘要: #include#include#include#include#include#include#include"Test.h"void replace(char *s) // 先计算空格总数,然后从后面开始替换,可以计算出空格后面字符的偏移量{ assert(s!=NULL); int len =strlen(s); int i,j; int x; for(i=0,x=0;i=0;i--) { if(s[i]==' ') { spaceCount++; int shift=(x-sp... 阅读全文
posted @ 2013-07-22 17:02 dyc0113 阅读(204) 评论(0) 推荐(0) 编辑
摘要: 题目: 在一个二维数组中,每一行都按照从左到右的递增顺序,每一列都按照从上到下的顺序排序。请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。1 2 8 92 4 9 124 7 10 136 8 11 15#include#include#include#include#include#include#include"Test.h"bool findMatrix(int **p,int m,int n,int x){ assert(p!=NULL); while(m>=1&&n>=1) { if(p[0][n-1]> 阅读全文
posted @ 2013-07-22 16:49 dyc0113 阅读(142) 评论(0) 推荐(0) 编辑
摘要: class Singleton // 这是两种方式{private: static Singleton single; Singleton(){} Singleton &operator=(Singleton & s)// 屏蔽拷贝构造函数和赋值操作符 { } Singleton(const Singleton &s){}public: int m_value; static Singleton * getInstance() { return &single; }};Singleton Singleton::... 阅读全文
posted @ 2013-07-22 15:54 dyc0113 阅读(115) 评论(0) 推荐(0) 编辑

导航