C++
文章平均质量分 68
chenxin_003
这个作者很懒,什么都没留下…
展开
-
BUG解析之0xC0000005: 读取位置 0x00000000 时发生访问冲突。
错误内容如下:原创 2014-07-30 12:11:04 · 7370 阅读 · 1 评论 -
Leetcode:subsets2 duplicate number
题目如下:Given a collection of integers that might contain duplicates, S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not co原创 2014-09-09 17:39:24 · 451 阅读 · 0 评论 -
Leetcode:Remove Duplicates from Sorted List
题目:Given a sorted linked list, delete all duplicates such that each element appear only once.For example,Given 1->1->2, return 1->2.Given 1->1->2->3->3, return 1->2->3.代码如下:原创 2014-09-02 18:51:29 · 402 阅读 · 0 评论 -
Leetcode Anagrams
题目:Given an array of strings, return all groups of strings that are anagrams.Note: All inputs will be in lower-case.代码如下:原创 2014-09-09 11:39:51 · 326 阅读 · 0 评论 -
Leetcode: Subsets
题目:Given a set of distinct integers, S, return all possible subsets.Note:Elements in a subset must be in non-descending order.The solution set must not contain duplicate subsets.原创 2014-09-09 16:56:52 · 458 阅读 · 0 评论 -
C++ 二分查找的递归与非递归实现
非常简单的东西,直接看看代码。/*二分查找的递归与非递归实现*/#include using namespace std;//设定为非重复的递增整数列:循环方法int BinarySearch(int array[],int value,int length){ if(array == NULL || length < 1) return -1; int lp = 0; i原创 2014-09-12 22:25:52 · 478 阅读 · 0 评论 -
C++ 求斐波那契数列 递归法 迭代法
代码:/*递归法、迭代法求斐波那契数列*/#include #include using namespace std;class Solution{public: int Fib(int n) { if(n == 0) return 0; if(n == 1) return 1; if(n > 1) return Fib(n-1) + Fib(n-原创 2014-09-14 11:23:20 · 7974 阅读 · 0 评论 -
C++ 求旋转字符串中的最小值
思路比较简单,直接看代码即可:/*求一个旋转字符串中最小值*//*思路:遇到没有旋转以及数组中相同位置元素相等的采用顺序查找*/#include #include #include using namespace std;class Solution{public: int find(int array[],int length) { int i=0, min = ar原创 2014-09-14 10:52:10 · 610 阅读 · 0 评论 -
C++ 调整数组使得奇数位于偶数后面
代码如下:/*调整数组的顺序使得数组中偶数在奇数前面*/#include #include using namespace std;class Solution{public: void swap(int &a ,int &b) { int temp = b; b = a; a = temp; } int * reorder(int array[],int le原创 2014-09-15 13:53:29 · 1352 阅读 · 0 评论 -
O(1)时间求一个栈的最小值
/*O(1)求出一个栈的最小值*/#include #include #include #define maxsize 10using namespace std;int main(){ stack source; stack compare; for(int i = 0;i < maxsize;i++) { int input; cin >> input;原创 2014-09-02 17:57:02 · 472 阅读 · 0 评论 -
C++ 合并链表
合并2个递增链表,使得合并后仍保持递增顺序:MergeList.cpp:原创 2014-09-16 11:04:54 · 897 阅读 · 0 评论 -
LeetCode: Linked List Cycle II
题目:Linked List Cycle II :Given a linked list, return the node where the cycle begins. If there is no cycle, return null.Follow up:Can you solve it without using extra space?代码:原创 2014-08-27 19:45:55 · 337 阅读 · 0 评论 -
PAT 1001 1002
PAT题目1001:解题思路:这道题,虽然看起来很简单,但是还是有很多细节要注意的。因为在运算各个位的时候,低位先得到,高位后得到,而要保证输出的顺序正确,所以采用了栈的结构。代码如下:#include #include #include #include using namespace std;int main(){ int原创 2014-08-15 19:09:23 · 431 阅读 · 0 评论 -
C++小实验之多态性理解
#include #include using namespace std;class Cup{public:virtual void color() = 0;};class TeaCup{public:virtual void color(){cout << "have a tea,change a mood " << endl;}};class Fathor{public:virtual vo原创 2014-08-01 15:11:22 · 489 阅读 · 0 评论 -
C++: 7种排序 算法原理展示
先贴上代码:(其中duipaipaixv)原创 2014-08-19 19:15:13 · 409 阅读 · 0 评论 -
C++ 判断栈的弹出序列是否正确
题目:给出一个栈的压入序列,判断给出的弹出序列是否正确。daima原创 2014-09-19 15:11:12 · 955 阅读 · 0 评论 -
C++ 从上到下,从左至右打印二叉树
代码如下:#include #include "BinaryTree.h"#include using namespace std;void PrintTree_from_head_to_tail(TreeNode* proot){ if(proot == NULL) return; deque tree_que; TreeNode* node = proot; tre原创 2014-09-19 15:51:18 · 1244 阅读 · 0 评论 -
C++ 二叉树中和为某一值的路径
思路:递归、判断技术条件、采用vector代码:原创 2014-09-20 01:19:43 · 768 阅读 · 0 评论 -
求一个长度为n的整型有序数组中是否有出现次数超过n/2的元素
面试题: 一个长度为n的整型有序数组,求这个原创 2014-08-12 20:49:29 · 3656 阅读 · 0 评论 -
C++ 求一个字符串的所有排列
代码如下:原创 2014-09-22 01:19:52 · 1699 阅读 · 0 评论 -
C++ 静态成员函数小练习
首先,我们可以先看1个小例子:原创 2014-09-10 13:25:56 · 598 阅读 · 0 评论 -
C++ 单例模式 拷贝构造函数 手动实现
单例模式 涉及到 智能指针,内存中的堆和栈代码如下:原创 2014-09-11 21:27:21 · 2402 阅读 · 0 评论 -
PAT 1065
PAT1065题目如下:原创 2014-08-15 19:06:23 · 436 阅读 · 0 评论 -
C++ 判断是否为2叉树的子树
题目:输入A.B 两棵树,判断原创 2014-09-16 15:16:16 · 643 阅读 · 0 评论