上一页 1 ··· 4 5 6 7 8
摘要: 1 #include <iostream> 2 #include <string> 3 #include <vector> 4 using namespace std; 5 6 //摘自程序员面试宝典 7 //输入两个字符串,比如abdbcc和abc,输出第二个字符串在第一个字符串中的连接次序 8 //即输出125,126,145,146 9 template <class T>10 void print(vector<T> v)11 {12 for (typename vector<T>::iterator it = v 阅读全文
posted @ 2013-05-09 10:42 weiwei5987 阅读(222) 评论(0) 推荐(0) 编辑
摘要: 1 #include <stdio.h> 2 #include <stdlib.h> 3 struct Node 4 { 5 int value; 6 Node * next; 7 }; 8 9 Node * reverse(Node * head)10 {11 Node * ret = NULL;12 while (head != NULL)13 {14 Node * temp = head->next;15 head->next = ret;1... 阅读全文
posted @ 2013-05-08 16:56 weiwei5987 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 压缩字符串,input:aaabbbccc output:3a3b3c 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 4 char* compress(const char * src, char *des) 5 { 6 if (des==NULL) 7 { 8 return NULL; 9 }10 int count = 1;11 int pointer = 0;12 char cu... 阅读全文
posted @ 2013-05-08 16:54 weiwei5987 阅读(243) 评论(0) 推荐(1) 编辑
摘要: 1 View Code 2 #include <iostream> 3 #include <vector> 4 using namespace std; 5 6 7 struct BinaryTreeNode 8 { 9 int m_nValue;10 BinaryTreeNode * m_pLeft;11 BinaryTreeNode * m_pRight;12 };13 14 15 void print(vector<int> & v)16 {17 for (vector<int>::i... 阅读全文
posted @ 2013-05-08 16:52 weiwei5987 阅读(176) 评论(0) 推荐(0) 编辑
摘要: 思路:首先用一个hash标识s2中出现的所有字符,count记录不重复的字符数,temp_count记录当前已经有的不重复字符数,用left和right指针扫描s1,用另一个hash记录left和right之间每个字符出现的次数。right每前进一步,如果指向的不是s2中的字符,继续前进,如果是s2中的字符,如果是第一次遇见该字符,temp_count加一,如果temp_count等于count则尽量右移left指针,left指针右移有两种情况:1.left指向的字符不在s2中。2.left指向的字符在s2中,且当前出现的次数大于1次。 1 #include <iostream> 阅读全文
posted @ 2013-04-25 11:37 weiwei5987 阅读(368) 评论(0) 推荐(0) 编辑
摘要: 一定要手写代码,如果简单觉得题目大致思路知道就可以,到面试时真的会捉急,atoi平时觉得很简单,可是真正写起来要考虑的太多了:1.滤掉前面空格。2.判断字符串开始符号。3.防止溢出。 这些都是原有atoi的操作,最后4.返回bool表示有没有出错的情况,这不是atoi的,是我们自己扩展的功能。 1 bool my_atoi(const char *p, int &num) 2 { 3 if (p==NULL) 4 { 5 return false; 6 } 7 while(*p == ' ') 8 ... 阅读全文
posted @ 2013-04-24 09:18 weiwei5987 阅读(188) 评论(0) 推荐(0) 编辑
摘要: set cindent set smartindent set autowrite "set enc=GBK set backspace=indent,eol,start "set fencs=GBK,utf-8,ucs-bom,cp936,latin1,big5,utf-16 set fileen 阅读全文
posted @ 2013-04-18 10:07 weiwei5987 阅读(199) 评论(0) 推荐(0) 编辑
上一页 1 ··· 4 5 6 7 8