
Code
MAZHEN1986
这个作者很懒,什么都没留下…
展开
-
queue
#include #include using namespace std; typedef struct _node { int data; _node *next; }Node; typedef struct linkqueue { linkqueue():first(NULL), rear(NULL){}; Node *first, *rear; }Queu原创 2012-10-06 21:36:35 · 430 阅读 · 0 评论 -
各种字符串Hash函数比较
http://www.byvoid.com/blog/string-hash-compare/常用的字符串Hash函数还有ELFHash,APHash等等,都是十分简单有效的方法。这些函数使用位运算使得每一个字符都对最后的函数值产生影响。另外还有以MD5和SHA1为代表的杂凑函数,这些函数几乎不可能找到碰撞。常用字符串哈希函数有BKDRHash,APHash,DJBHash,J转载 2012-11-12 00:07:43 · 738 阅读 · 0 评论 -
C/C++中static关键字详解
http://www.cnblogs.com/yc_sunniwell/archive/2010/07/14/1777441.html静态变量作用范围在一个文件内,程序开始时分配空间,结束时释放空间,默认初始化为0,使用时可以改变其值。 静态变量或静态函数只有本文件内的代码才能访问它,它的名字在其它文件中不可见。用法1:函数内部声明的static变量,可作为对象间的一种通信机转载 2012-11-11 14:27:31 · 791 阅读 · 0 评论 -
KMP 记录一下
/* strstr example */#include #include #include using namespace std;void get_nextval(char *p,int *next) { int j,k; next[0]=-1; j=0; k=-1; while(j<strlen(p)-1) { if(k==-1||p[j]==p[k])转载 2012-10-20 17:40:50 · 646 阅读 · 0 评论 -
类斐波那契数列问题
question:给你一个无线延伸的2D空间,由一个个方格构成,初始你在某一空格上,你可以往上,左,右走,但是不能往下走,并且走过的地方不能再走(已经下陷)。求:N步有多少种可能???answer:因为不可以走同样的地方,f(n)表示走n步有多少种可能,所以:1、往上走,进入f(n-1)2、左,右走进入 g(n-1),之后可以往上进入f(n-2),或是继续前一步的方向走进入原创 2012-11-11 17:04:49 · 661 阅读 · 0 评论 -
微软校园招聘面试经历
1、泛函,编译器的实现 模板,泛函编程编译器原理:C++ primer 第四版 P535模板是一个蓝图,本身不是类或函数,编译器是通过重新编写模板类,用特定类型代替模板中的类型,自动创建特定名的模板的类。2、死锁代码实现..3、BigInt类实现+ - =操作符重载,注意内存泄露,可以用char *实现(内存消耗大),也可以用小整数实现。4、二叉查找树的判原创 2012-10-30 13:33:30 · 1239 阅读 · 0 评论 -
类 丑数
#include #include using namespace std; void main() { queuetriqueue; queuefivqueue; queuesevqueue; triqueue.push(3); fivqueue.push(5); sevqueue.push(7); int num = 40; int i = 0; while(i原创 2012-10-20 00:07:54 · 534 阅读 · 0 评论 -
双栈实现队列
#include #include #include using namespace std;templateclass CQueue{public: CQueue(){}; ~CQueue(){}; void push_back(T data); T pop_front(); bool empty();public: CQueue(T *pdata, int len原创 2012-10-17 23:46:06 · 726 阅读 · 0 评论 -
C++ stack栈 树建立
stackmystack; for (int i = 0; i< 10; i++) { mystack.push(i); } while(!(mystack.empty())) { int data = mystack.top(); cout<<data<<endl; mystack.pop(); }#include #include #include us原创 2012-10-17 23:19:42 · 1023 阅读 · 0 评论 -
简单括号匹配code
#include#define MAX 100int match(char *str){ char stack[MAX],*p=stack; while(*str) { switch(*str) { case '(': { *p++=*str; break; } case ')': { if(*--p!='(') re转载 2012-10-12 00:05:43 · 625 阅读 · 0 评论 -
图的遍历- 图内多环 多连通图问题
http://www.cnblogs.com/dolphin0520/archive/2011/07/13/2105236.html递归 非递归(用栈)图的遍历有两种遍历方式:深度优先遍历(depth-first search)和广度优先遍历(breadth-first search)。1.深度优先遍历 基本思想:首先从图中某个顶点v0出发,访问此顶点,然后转载 2012-10-12 00:25:38 · 1230 阅读 · 0 评论 -
数组 寻找数
数组行列都是非递减#include #include #include using namespace std;bool Find(int *martrix, int rows, int columns, int number){ int i = 0; int j = 0; while(i < rows && i < columns) { cout<<martrix[i*原创 2012-10-10 00:32:52 · 464 阅读 · 0 评论 -
String
#include #include using namespace std;class String{public: String(const char *str = NULL); String(const String &another); ~String(); String &operator = (const String *rhs); friend ostream&原创 2012-10-08 11:44:56 · 503 阅读 · 0 评论 -
FibonacciSequence
#include #include using namespace std;long long FibonacciSequenceFunction(long long *pLongInt, int n){ if( pLongInt[n] != 0 ) return pLongInt[n]; else{ pLongInt[n] = FibonacciSequenceFunc原创 2012-10-08 22:52:11 · 593 阅读 · 0 评论 -
UglyNumber
#include #include using namespace std;//只包含因子2、3和5的数称作丑数(Ugly Number)bool IsUgly(int number){ while(number % 2 == 0) number /= 2; while(number % 3 == 0) number /= 3; while(number % 5 ==原创 2012-10-08 22:35:58 · 476 阅读 · 0 评论 -
itoa
#include #include using namespace std;//整形double myItoa(const char *pChar){ //空指针 if(pChar == NULL) { printf("NULL pointer\n"); return 0; } int len = strlen(pChar); if( 0 == len )原创 2012-10-08 12:08:15 · 508 阅读 · 0 评论 -
shell 按行读取并保存成数组
博主:http://mark-ztw.iteye.com/blog/1535480shell 按行读取并保存成数组 从ip.txt里读取IP.然后把IP地址赋值到一个数组里. IP文件如下: Address: 220.181.26.163 Address: 220.181.26.174 Address: 220.181.26.175 Address:转载 2012-11-15 15:42:33 · 16914 阅读 · 3 评论