- 博客(17)
- 资源 (3)
- 收藏
- 关注
原创 C++ Reflection
// class_factory.h#include <map> #include <string> #include <functional> #include <memory> template <typename classType> class ClassFactory { private: ClassFactory()...
2018-05-04 17:30:29 891 1
原创 无符号整数的bitmap
#include #include #include using namespace std; /* * // 0000 0000 八个bit位,每一位标志一个数是否存在 * unsigned char bit_table[8]{1, 2, 4, 8, 16, 32, 64, 128}; * * unsigned char c = 0; * c |= bit_tab
2017-08-27 17:17:53 339
原创 smart_ptr智能指针的简单实现
// // Created by yudw on 2017/8/7. // #pragma once namespace yudw { template typename T> class smart_pointer { public: // 需要显示构造 explicit smart_pointer(T* p): p_(p),
2017-08-07 14:07:34 387
原创 memcpy
// // Created by yudw on 2017/8/6. // #pragma once #include #define debug_ namespace yudw { // 注意当内存有重叠时,src部分会被覆盖 void* memcpy(void *dst, const void* src, size_t size) { if(
2017-08-07 10:46:14 12317
原创 strcpy
// // Created by yudw on 2017/8/7. // #pragma once #include namespace yudw { char* strcpy(char *dest, char *src) { assert(dest != nullptr && src != nullptr); char *p = dest
2017-08-07 08:54:32 580
原创 MyString
// // Created by yudw on 2017/8/6. // #ifndef MYFISTAPP_MYSTRING_H #define MYFISTAPP_MYSTRING_H #include namespace yudw { class MyString { public: MyString(const char *data = n
2017-08-06 20:57:46 403
原创 动态规划问题的解决步骤
leetcode198 House RobberYou are a professional robber planning to rob houses along a street. Each house has a certain amount of money stashed, the only constraint stopping you from robbing each of them
2017-07-30 12:16:40 580
原创 10.二进制中1的个数
#include <iostream>using namespace std;class Solution { public: int NumberOf1(int n) { int CntOf1 = 0; while(n) { n = n&(n-1); //能将n的二进制表示中最后一位1置0
2017-04-18 14:24:05 195
原创 9.斐波那契数列
#include <iostream> #include <ctime> #include <time.h> using namespace std;long long Fibonacci_Recursion(unsigned int n) { if(n <= 1) return n; return Fibonacci_Recursion(n-1) + Fibonacc
2017-04-18 14:18:04 193
原创 8.旋转数组的最小数
#include <iostream> #include <queue> #include <stack> using namespace std; template <typename T> class CQueue { public: CQueue(){} ~CQueue(){} void push(const T& val); const T& pop();pri
2017-04-18 14:14:04 192
原创 7.两个栈实现一个队列
#include <iostream> #include <queue> #include <stack> using namespace std; template <typename T> class CQueue { public: CQueue(){} ~CQueue(){} void push(const T& val); const T& pop();pri
2017-04-18 14:13:10 237
原创 6.重建二叉树
#include <iostream> #include <exception> #include <queue> #include <stack> using namespace std;struct BinaryTreeNode { int m_nValue; BinaryTreeNode* m_pLeft; BinaryTreeNode* m_pRight; }
2017-04-18 14:10:33 203
原创 5.从尾到头打印链表
#include <iostream> #include <stack> using namespace std;struct ListNode { int m_nValue; ListNode* m_pNext; };void PrintReverseList(ListNode* pHead) { if(pHead == nullptr) return;
2017-04-18 13:51:12 189
原创 4.空格替换
#include <iostream> #include <cstring> #include <algorithm> using namespace std;void ReplaceBlank(char str[], int length) { if(str == nullptr) return; int len = strlen(str); int blan
2017-04-18 13:49:54 162
原创 3.在二维数组中查找
#include <iostream>using namespace std;bool Find(int* matrix, int rows, int columns, int number) { bool found = false; if(matrix!=nullptr && rows>0 && columns>0) { int row = 0;
2017-04-18 13:48:30 176
原创 2.实现Singleton模式
#include <iostream> #include <thread> using namespace std;class Singleton { private: static Singleton* p;private: Singleton(){ } Singleton(const Singleton&){}public: int a; static Si
2017-04-18 13:45:59 261
原创 1.赋值运算符函数
#include <iostream> #include <cstring> #include <utility> // std::swapusing namespace std; class MyString { public: MyString(char* pData=nullptr); MyString(const MyString& ms); ~MyStri
2017-04-18 13:42:50 201
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人