摘要: // 这种解法需要循环32次int BinaryOneNum(int iNum){#if 0 int iCount = 0; for (int i = 0; i > 1; } return iCount;}// 最优解法// 1100 --> 减一 --> 1001// 1100 & 1001 --> 1000int BinaryOneNum_2(int iN... 阅读全文
posted @ 2019-07-28 13:30 VIP丶可乐 阅读(122) 评论(0) 推荐(0) 编辑
摘要: /////////////////////////////////////////////////////////////////////////////////////////////// 13.题目九:斐波那契数列/*写一个函数,输入N,求斐波那契(Fibonacci)数列的第N项.F(n) = {0 n == 0; 1 n == 1; F(n -1... 阅读全文
posted @ 2019-07-28 13:15 VIP丶可乐 阅读(212) 评论(0) 推荐(0) 编辑
摘要: ///////////////////////////////////////////////////////////////////////////////////////////////12. 题目八:旋转数组的最小数字int RotatedBinarySearchMinNum(int aiArray[], int iLen){ int iLeft = 0; int iMid = ... 阅读全文
posted @ 2019-07-28 13:14 VIP丶可乐 阅读(109) 评论(0) 推荐(0) 编辑
摘要: ////////////////////////////////////////////////////////////////////////////////////// 10.题目七:用两个栈实现队列// 题目:用两个栈实现一个队列,队列的声明如下:template class CQueue{public: CQueue(){} ~CQueue(){} void Append... 阅读全文
posted @ 2019-07-28 13:13 VIP丶可乐 阅读(107) 评论(0) 推荐(0) 编辑
摘要: ///////////////////////////////////////////////////////////////////////////////////////// // 9.题目六:重建二叉树// 题目:输入某二叉树的前序遍历和中序遍历的结果,请重建出改二叉树struct BinaryTreeNode{ int m_iValue; BinaryTreeNode* m_p... 阅读全文
posted @ 2019-07-28 13:12 VIP丶可乐 阅读(135) 评论(0) 推荐(0) 编辑
摘要: //////////////////////////////////////////////////////////////////////////////////////////////// 8.题目五:从尾到头打印链表// 方法一:时间复杂度O(n),空间复杂度O(n)template void ReversePrintList1(ListNode* pNode){ assert(NUL... 阅读全文
posted @ 2019-07-28 13:11 VIP丶可乐 阅读(94) 评论(0) 推荐(0) 编辑
摘要: //////////////////////////////////////////////////////////////////////////////// 6.题目四:替换空格// 请实现一个函数,把字符串中每个空格替换成"%20";例如输入:"We Are Happy!" --> "We%20Are%20Happy!"//时间复杂度O(n), 空间复杂度O(1)char* StrRepla... 阅读全文
posted @ 2019-07-28 13:10 VIP丶可乐 阅读(115) 评论(0) 推荐(0) 编辑
摘要: //二位数组查找 题目描述//在一个二维数组中(每个一维数组的长度相同),每一行都按照从左到右递增的顺序排序,每一列都按照从上到下递增的顺序排序。//请完成一个函数,输入这样的一个二维数组和一个整数,判断数组中是否含有该整数。bool FindNum(int target, vector > vect){ int iRow = vect.size(); int iCol = vec... 阅读全文
posted @ 2019-07-28 13:07 VIP丶可乐 阅读(98) 评论(0) 推荐(0) 编辑
摘要: ////////////////////////////////////////////////////////////////////////////////////////////////////////// 4.单例模式测试extern CMutex g_stMutex; // 这个在ThreadTest.cpp中定义了,这个声明一下!!!!class CSingletonTest{p... 阅读全文
posted @ 2019-07-28 13:05 VIP丶可乐 阅读(207) 评论(0) 推荐(0) 编辑
摘要: /////////////////////////////////////////////////////////////////////////////////////////////// 3.题目一:赋值运算符函数class CMyString{public: // 默认函数 CMyString(); CMyString(const CMyString&); CMySt... 阅读全文
posted @ 2019-07-28 13:03 VIP丶可乐 阅读(214) 评论(0) 推荐(0) 编辑