自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(21)
  • 问答 (1)
  • 收藏
  • 关注

原创 图求最短路径

class DeepTrace{public: void InitMap(const vector<vector<int> > vMap, const int &portNum) { m_map = vMap; m_portNum = portNum; m_traceTree.clear(); } bool GetRu

2015-09-17 18:06:43 426

原创 小算法:一个排名区间,对应一个奖品,给定一个排名区间,判断它要领取奖品的id

vector<int> m_vRankRegion;m_vRankRegion.push_back(1);//1 - 1m_vRankRegion.push_back(1);//2 - 2m_vRankRegion.push_back(1);//3 - 3m_vRankRegion.push_back(1);//4 - 4m_vRankRegion.push_back(1);//5 - 5

2015-09-07 20:16:05 455

原创 Viemu for 2008 如何高亮选中的单词?

Viemu for 2008 如何高亮选中的单词? 答:vim内置的命令gd,*,#, 但是会引起光标移动,怎么才能高亮选中的单词, 但又不移动光标呢。 步骤1:在windows下,建立C:/User/Adminstrator/_viemurc 步骤2:在_viemurc写入 步骤3::重启VS2008吧,然后光标选中单

2015-07-09 21:47:28 590

原创 两个队列模拟一个栈

思路就是两个队列切换来切换去。个人代码如下:#include #include using namespace std;class CStack{public: void pop(); int top(); void push(int elem); void Move(queue &des, queue &sour, int begin, int end); CSta

2015-02-09 19:13:12 423

转载 AVL树的旋转操作 图解 最详细

转载地址: http://blog.csdn.net/collonn/article/details/20128205

2015-02-01 22:06:20 381

原创 二叉搜索树(二叉排序树)

开始个人树的学习: 二叉搜索树->平衡树AVL->红黑树参考的博客地址://http://blog.chinaunix.net/uid-27033491-id-3301179.html个人代码如下://http://blog.chinaunix.net/uid-27033491-id-3301179.html#include using namespace std;//二叉搜索

2015-01-28 22:31:31 480

原创 设计模式之单例模式

个人代码如下:#include #include using namespace std;class CSingleton{private: static CSingleton* pObject; CSingleton(){pObject = NULL; strName = "im Singleton";}public: string strName; static CS

2015-01-26 23:37:28 458

原创 Abbott 的复仇(Abbott's Revenge,ACM|IPPC World Finals 2000, UVa 816)

代码如下:#include #include using namespace std;//const char * dirs = "NESW";//const char * turns = "FLR";const int N = 0, E = 1, S = 2, W = 3;const int F = 0, L = 1, R = 2;//分别表示N(上),E(右),S(下),

2015-01-25 15:37:40 2183

原创 链表反转

个人代码如下:#include using namespace std;typedef struct STNode{ int data; struct STNode *next;}Node;void CreateList(Node *&Root, int len){ Node *pNewNode = NULL; for(int i = 0; i < len; ++i)

2015-01-21 23:07:51 415

原创 编写一个单词反转,字符不反转的函数。

如题:规则如下输入:im a bad student输出:student bad a im方法1:不借助辅助的空间#include #include using namespace std;void ReverseWord(char a[], int begin, int end){ for(; begin < end; ++begin, --end) swap(a

2015-01-17 20:24:46 564

原创 求第n个斐波那契数的值(递归和非递归解法)

个人代码如下:(1)递归:long long Fbl(int n){ if(n == 1 || n == 2) return 1; return Fbl(n-2) + Fbl(n-1);}int main(){ //1 1 2 3 5 8 cout<< Fbl(4); return 0;}(2)非递归:long long Fbl(int n){ if

2015-01-17 19:42:41 638

原创 图的入门之的深度遍历

PS:终于开始图的学习之旅了,先来个开胃小菜,图的深度遍历,个人代码如下:#include#includeusing namespace std;void dfs(char a[][5], int row, int col, int r, int c, const char tag = '#'){ if(r row - 1 || c col - 1) return; if(t

2015-01-16 22:04:11 468

原创 二分查找之天平称重,称出最重的小球

题目:有n个小球,其中有一个比其他的都要重,已知有一个天平,怎么用最少的次数把小球找出来?个人代码如下:#include #include using namespace std;int GetAbnormalBall(int a[], int begin, int end, int &count){ if(begin == end) return a[begin];

2015-01-16 21:37:04 1443

原创 天平 (Not so Mobile, UVa 839)

题意:输入一个树状天平,根据力矩相等的原则判断是否平衡。就是W1D1= W2D2,其中W1,W2分别为左右两边砝码的重量,D为距离。示意图如下:个人代码如下:#include using namespace std;#define IsLeaf(w1, w2) ((w1) && (w2))bool solve(int &w){ int W1, L1, W2, L2;

2015-01-08 10:53:03 501

原创 排序算法之归并排序

归并排序代码如下:#include using namespace std;void MergeArray(int a[], int begin1, int end1, int begin2, int end2){ int begin = begin1; const int len = end2 - begin1 + 1; int b[len]; int pos = 0; w

2015-01-07 09:55:54 404

原创 查找算法之二分查找

二分查找的代码如下:#include #include using namespace std;long BinarySearch(int a[], int begin, int end, int elem){ if(begin > end) return -1; int mid = (begin + end) / 2; //int mid = begin + (end -

2015-01-07 09:28:37 428

原创 排序算法之堆排序

堆排序的算法如下:#include using namespace std;void AdjustHeap(int a[], int begin, int end, int pos){ int lchild = 2 * pos - begin + 1; int rchild = 2 * pos - begin + 2; int TracePos = -1; if(lchild

2015-01-06 21:57:54 422

原创 排序算法之快速排序

快速排序的代码如下:#include #include using namespace std;int SortByOnce(int a[], int begin, int end);void QuickSort(int a[], int begin, int end);bool CheckResultIsRight(int a[], int len);int main(){

2014-12-28 14:59:56 376

原创 2014年去哪网算法笔试题

题目一:1.写一个函数,转换相对路径为绝对路径,比如:/home/abs/../temp/new/../,输出路径为:/home/temp。1.写一个函数,转换相对路径为绝对路径,比如:/home/abs/../temp/new/../,输出路径为:/home/temp。1.写一个函数,转换相对路径为绝对路径,比如:/home/abs/../temp/new

2014-12-24 00:49:22 477

原创 friend (友元的一个妙用)

在软件设计的时候,我们如果希望一个对象只能由另一个对象生成,比如水果农厂里面可以结出各种各样的水果,而水果不能平白无故的产生。所以水果对象的构造函数肯定是private,而水果农厂却可以NewFruit(), 其中将水果农厂(CFruitFarm)作为友元,插入到各种水果当中就可以实现这个效果。下面举例说明:#include #include using namespace std

2014-12-23 10:42:36 628

原创 破损的键盘(Broken KeyBoard)Uva 11988

样例输入:This_is_a_[Beiju]_text[[]][][]Happy_Birthday_to_Tsinghua_University样例输出:BeijuThis_is_a_textHappy_Birthday_to_Tsinghua_University静态链表的实现:(用结构体数组模拟链表)#include using namespace

2014-12-21 14:46:38 619

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除