├── .gitignore
├── Algorithm
├── Algorithm.cpp
├── Algorithm.vcxproj
├── Algorithm.vcxproj.filters
├── ReadMe.txt
├── matrix_udg.cpp
├── matrix_udg.h
├── stdafx.cpp
├── stdafx.h
├── targetver.h
└── 动态规划-优化编辑器问题.cpp
├── BasicTest
├── BasicTest.cpp
├── BasicTest.vcxproj
├── BasicTest.vcxproj.filters
├── ReadMe.txt
├── stdafx.cpp
├── stdafx.h
└── targetver.h
├── DesignPattern
├── 10组合模式.cs
├── 1单例模式.cs
├── 2简单工厂.cs
├── 3工厂方法.cs
├── 4_2抽象工厂新增工厂.cs
├── 4抽象工厂.cs
├── 5建造者模式.cs
├── 6原型模式.cs
├── 7适配器模式.cs
├── 8桥接模式.cs
├── 9装饰器模式.cs
├── App.config
├── DesignPattern.csproj
├── DesignPattern.sln
├── Form1.Designer.cs
├── Form1.cs
├── Form1.resx
├── Program.cs
└── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
├── HuaWei
├── 10字符个数统计.cpp
├── 11数字颠倒.cpp
├── 12字符串反转.cpp
├── 13句子逆序.cpp
├── 14字串的连接最长路径查找.cpp
├── 15求int型正整数在内存中存储时1的个数.cpp
├── 16购物单.cpp
├── 17坐标移动.cpp
├── 18识别有效的IP地址和掩码并进行分类统计.cpp
├── 19简单错误练习.cpp
├── 1字符串最后一个单词的长度.cpp
├── 20密码验证合格程序.cpp
├── 21简单密码.cpp
├── 22汽水瓶.cpp
├── 23删除字符串中出现次数最少的字符.cpp
├── 24合唱队.cpp
├── 25数据分类处理.cpp
├── 26字符串排序.cpp
├── 27查找兄弟单词.cpp
├── 28素数伴侣.cpp
├── 29字符串加解密.cpp
├── 2计算字符个数.cpp
├── 30字符串合并处理.cpp
├── 31单词倒排.cpp
├── 32字符串运用-密码截取.cpp
├── 33整数与IP地址间的转换.cpp
├── 34图片整理.cpp
├── 35蛇形矩阵.cpp
├── 36字符串加密.cpp
├── 37统计每个月兔子的总数.cpp
├── 38求小球落地5次后所经历的路程和第5次反弹的高度.cpp
├── 39判断两个IP是否属于同一子网.cpp
├── 3明明的随机数.cpp
├── 40输入一行字符,分别统计出包含英文字母空格数字和其它字符的个数.cpp
├── 41称砝码.cpp
├── 42学英语.cpp
├── 43迷宫问题.cpp
├── 44Sudoku.cpp
├── 45名字的漂亮度.cpp
├── 46按字节截取字符串.cpp
├── 47线性插值.cpp
├── 48从单向链表中删除指定值的节点.cpp
├── 49多线程.cpp
├── 4字符串分隔.cpp
├── 50四则运算.cpp
├── 5进制转换.cpp
├── 6质数因子.cpp
├── 7取近似值.cpp
├── 8合并表记录.cpp
├── 9提取不重复的整数.cpp
├── HuaWei.cpp
├── HuaWei.h
├── HuaWei.vcxproj
├── HuaWei.vcxproj.filters
├── ReadMe.txt
├── a清一色.cpp
├── stdafx.cpp
├── stdafx.h
├── targetver.h
├── 成绩排序.cpp
├── 找出字符串中第一个只出现一次的字符.cpp
├── 火车进站.cpp
├── 计算字符串的距离.cpp
├── 高精度整数加法.cpp
└── 高精度整数加法.py
├── LICENSE
├── LeetCode
├── LeetCodeCSharp
│ ├── App.config
│ ├── FormMain.Designer.cs
│ ├── FormMain.cs
│ ├── FormMain.resx
│ ├── LeetCodeCSharp.csproj
│ ├── Program.cs
│ ├── Properties
│ │ ├── AssemblyInfo.cs
│ │ ├── Resources.Designer.cs
│ │ ├── Resources.resx
│ │ ├── Settings.Designer.cs
│ │ └── Settings.settings
│ └── 算法
│ │ ├── 155.cs
│ │ ├── 535.cs
│ │ ├── 657.cs
│ │ ├── 709.cs
│ │ ├── 804.cs
│ │ ├── 852.cs
│ │ └── 867.cs
├── LeetCodeCpp
│ ├── 1.cpp
│ ├── 101对称二叉树.cpp
│ ├── 102二叉树的层次遍历.cpp
│ ├── 104.cpp
│ ├── 108将有序数组转换为二叉搜索树.cpp
│ ├── 111二叉树的最小深度.cpp
│ ├── 121.cpp
│ ├── 122.cpp
│ ├── 125.cpp
│ ├── 128.cpp
│ ├── 132分隔回文串.cpp
│ ├── 136.cpp
│ ├── 14.cpp
│ ├── 141.cpp
│ ├── 15.cpp
│ ├── 155.cpp
│ ├── 171.cpp
│ ├── 189.cpp
│ ├── 19.cpp
│ ├── 191.cpp
│ ├── 198.cpp
│ ├── 2.cpp
│ ├── 204计数质数.cpp
│ ├── 206.cpp
│ ├── 21.cpp
│ ├── 214.cpp
│ ├── 217.cpp
│ ├── 220.cpp
│ ├── 226翻转二叉树.cpp
│ ├── 231.cpp
│ ├── 234.cpp
│ ├── 237删除链表中的节点.cpp
│ ├── 242.cpp
│ ├── 278.cpp
│ ├── 28.cpp
│ ├── 283.cpp
│ ├── 3.cpp
│ ├── 326.cpp
│ ├── 338.cpp
│ ├── 342.cpp
│ ├── 344.cpp
│ ├── 349.cpp
│ ├── 350.cpp
│ ├── 38.cpp
│ ├── 384打乱数组.cpp
│ ├── 387.cpp
│ ├── 44.cpp
│ ├── 46.cpp
│ ├── 461.cpp
│ ├── 476.cpp
│ ├── 48.cpp
│ ├── 53.cpp
│ ├── 537.cpp
│ ├── 617合并二叉树.cpp
│ ├── 654最大二叉树.cpp
│ ├── 657.cpp
│ ├── 7.cpp
│ ├── 70.cpp
│ ├── 709.cpp
│ ├── 728.cpp
│ ├── 78.cpp
│ ├── 8.cpp
│ ├── 814二叉树剪枝.cpp
│ ├── 832.cpp
│ ├── 846.cpp
│ ├── 861.cpp
│ ├── 868.cpp
│ ├── 88合并两个有序数组.cpp
│ ├── 94.cpp
│ ├── 98.cpp
│ ├── LeetCodeCpp.cpp
│ ├── LeetCodeCpp.rc
│ ├── LeetCodeCpp.vcxproj
│ ├── LeetCodeCpp.vcxproj.filters
│ ├── LeetCodeCppTest.h
│ ├── ListNode.h
│ ├── ReadMe.txt
│ ├── TreeNode.h
│ ├── resource.h
│ ├── stdafx.cpp
│ ├── stdafx.h
│ └── targetver.h
├── LeetCodePython
│ ├── 349.py
│ ├── 566.py
│ └── LeetCodePython.pyproj
└── LeetCodeSql
│ ├── 175组合两个表.sql
│ ├── 182.sql
│ ├── 595.sql
│ ├── 620有趣的电影.sql
│ ├── LeetCodeSql.vcxproj
│ └── LeetCodeSql.vcxproj.filters
├── LinkList
├── LinkList.vcxproj
├── LinkList.vcxproj.filters
├── ReadMe.txt
├── josephu_problem.cpp
├── link_list.cpp
├── link_list.h
├── link_list_main.cpp
├── single_curcular_linked_list.cpp
├── stdafx.cpp
├── stdafx.h
└── targetver.h
├── README.md
├── STL
├── ReadMe.txt
├── STL.vcxproj
├── STL.vcxproj.filters
├── list.cpp
├── map.cpp
├── set.cpp
├── stdafx.cpp
├── stdafx.h
├── stl_demo.h
├── stl_main.cpp
├── targetver.h
├── vector.cpp
└── 常用算法.cpp
├── Search
├── ReadMe.txt
├── Search.vcxproj
├── Search.vcxproj.filters
├── binary_search.cpp
├── block_search.cpp
├── fibonacci_search.cpp
├── hash_search.cpp
├── insertion_search.cpp
├── search.h
├── search_main.cpp
├── sequence_search.cpp
├── stdafx.cpp
├── stdafx.h
├── targetver.h
├── tree_search.cpp
└── 性能对比.jpg
├── Stack
├── ReadMe.txt
├── Stack.vcxproj
├── Stack.vcxproj.filters
├── StackDemo.h
├── array_stack.cpp
├── stack_main.cpp
├── stdafx.cpp
├── stdafx.h
└── targetver.h
├── Test
├── LeetCodeCppTest
│ ├── LeetCodeCppTest.vcxproj
│ ├── LeetCodeCppTest.vcxproj.filters
│ ├── stdafx.cpp
│ ├── stdafx.h
│ ├── targetver.h
│ └── unittest1.cpp
├── STLTest
│ ├── STLTest.vcxproj
│ ├── STLTest.vcxproj.filters
│ ├── stdafx.cpp
│ ├── stdafx.h
│ ├── targetver.h
│ └── unittest_stl.cpp
├── SearchTest
│ ├── SearchTest.vcxproj
│ ├── SearchTest.vcxproj.filters
│ ├── stdafx.cpp
│ ├── stdafx.h
│ ├── targetver.h
│ └── unittest_search.cpp
└── SortTest
│ ├── UnitTest1.vcxproj
│ ├── UnitTest1.vcxproj.filters
│ ├── stdafx.cpp
│ ├── stdafx.h
│ ├── targetver.h
│ └── unittest_sort.cpp
├── ThreadCSharp
├── App.config
├── Form1.Designer.cs
├── Form1.cs
├── Form1.resx
├── Program.cs
├── Properties
│ ├── AssemblyInfo.cs
│ ├── Resources.Designer.cs
│ ├── Resources.resx
│ ├── Settings.Designer.cs
│ └── Settings.settings
└── ThreadCSharp.csproj
├── ThreadCpp
├── 1_thread.cpp
├── 2_move.cpp
├── 3_mutex.cpp
├── 4_timed_mutex.cpp
├── 5_thread_local_storage.cpp
├── 6_condition_variable.cpp
├── 7_atomic.cpp
├── 8_call_once.cpp
├── ReadMe.md
├── ThreadCpp.cpp
├── ThreadCpp.vcxproj
├── ThreadCpp.vcxproj.filters
├── ThreadLearning.h
├── stdafx.cpp
├── stdafx.h
└── targetver.h
├── TreeCpp
├── BiTree.h
├── Huffman.h
├── HuffmanNode.h
├── MinHeap.h
├── ReadMe.txt
├── TreeCpp.vcxproj
├── TreeCpp.vcxproj.filters
├── TreeCpp_main.cpp
├── stdafx.cpp
├── stdafx.h
└── targetver.h
├── string
├── ReadMe.txt
├── stdafx.cpp
├── stdafx.h
├── string.cpp
├── string.vcxproj
├── string.vcxproj.filters
└── targetver.h
├── templateDemo
├── BiTree.cpp
├── BiTree.h
├── ReadMe.txt
├── stdafx.cpp
├── stdafx.h
├── targetver.h
├── templateDemo.cpp
├── templateDemo.vcxproj
└── templateDemo.vcxproj.filters
├── 基础
├── 位运算
│ ├── BitOperation.cpp
│ ├── BitOperation.h
│ ├── ReadMe.txt
│ ├── stdafx.cpp
│ ├── stdafx.h
│ ├── targetver.h
│ ├── 位运算.cpp
│ ├── 位运算.vcxproj
│ └── 位运算.vcxproj.filters
├── 内存管理
│ └── memory
│ │ ├── ReadMe.md
│ │ ├── memory.cpp
│ │ ├── memory.vcxproj
│ │ ├── memory.vcxproj.filters
│ │ ├── stdafx.cpp
│ │ ├── stdafx.h
│ │ └── targetver.h
└── 指针
│ └── pointer
│ ├── ReadMe.md
│ ├── pointer.cpp
│ ├── pointer.vcxproj
│ ├── pointer.vcxproj.filters
│ ├── ptr.h
│ ├── stdafx.cpp
│ ├── stdafx.h
│ ├── targetver.h
│ └── unique_ptr_demo.cpp
├── 排序
├── ReadMe.txt
├── insertion_sort.cpp
├── merge_sort.cpp
├── selection_sort.cpp
├── sort.h
├── sort_main.cpp
├── stdafx.cpp
├── stdafx.h
├── swap_sort.cpp
├── targetver.h
├── 排序.vcxproj
├── 排序.vcxproj.filters
└── 算法复杂度表格.png
└── 面试基础.sln
/Algorithm/Algorithm.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/landbroken/BasicKnowledge/77b2ee482b1648c14b75bfa0971a08d91286d3e3/Algorithm/Algorithm.cpp
--------------------------------------------------------------------------------
/Algorithm/Algorithm.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | 头文件
23 |
24 |
25 | 头文件
26 |
27 |
28 | 头文件
29 |
30 |
31 |
32 |
33 | 源文件
34 |
35 |
36 | 源文件
37 |
38 |
39 | 源文件
40 |
41 |
42 | 源文件
43 |
44 |
45 |
--------------------------------------------------------------------------------
/Algorithm/ReadMe.txt:
--------------------------------------------------------------------------------
1 | ========================================================================
2 | 控制台应用程序:Algorithm 项目概述
3 | ========================================================================
4 |
5 | 应用程序向导已为您创建了此 Algorithm 应用程序。
6 |
7 | 本文件概要介绍组成 Algorithm 应用程序的每个文件的内容。
8 |
9 |
10 | Algorithm.vcxproj
11 | 这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。
12 |
13 | Algorithm.vcxproj.filters
14 | 这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。
15 |
16 | Algorithm.cpp
17 | 这是主应用程序源文件。
18 |
19 | /////////////////////////////////////////////////////////////////////////////
20 | 其他标准文件:
21 |
22 | StdAfx.h, StdAfx.cpp
23 | 这些文件用于生成名为 Algorithm.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。
24 |
25 | /////////////////////////////////////////////////////////////////////////////
26 | 其他注释:
27 |
28 | 应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。
29 |
30 | /////////////////////////////////////////////////////////////////////////////
31 |
--------------------------------------------------------------------------------
/Algorithm/matrix_udg.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/landbroken/BasicKnowledge/77b2ee482b1648c14b75bfa0971a08d91286d3e3/Algorithm/matrix_udg.cpp
--------------------------------------------------------------------------------
/Algorithm/matrix_udg.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/landbroken/BasicKnowledge/77b2ee482b1648c14b75bfa0971a08d91286d3e3/Algorithm/matrix_udg.h
--------------------------------------------------------------------------------
/Algorithm/stdafx.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/landbroken/BasicKnowledge/77b2ee482b1648c14b75bfa0971a08d91286d3e3/Algorithm/stdafx.cpp
--------------------------------------------------------------------------------
/Algorithm/stdafx.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/landbroken/BasicKnowledge/77b2ee482b1648c14b75bfa0971a08d91286d3e3/Algorithm/stdafx.h
--------------------------------------------------------------------------------
/Algorithm/targetver.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/landbroken/BasicKnowledge/77b2ee482b1648c14b75bfa0971a08d91286d3e3/Algorithm/targetver.h
--------------------------------------------------------------------------------
/Algorithm/动态规划-优化编辑器问题.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/landbroken/BasicKnowledge/77b2ee482b1648c14b75bfa0971a08d91286d3e3/Algorithm/动态规划-优化编辑器问题.cpp
--------------------------------------------------------------------------------
/BasicTest/BasicTest.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/landbroken/BasicKnowledge/77b2ee482b1648c14b75bfa0971a08d91286d3e3/BasicTest/BasicTest.cpp
--------------------------------------------------------------------------------
/BasicTest/BasicTest.vcxproj.filters:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | {4FC737F1-C7A5-4376-A066-2A32D752A2FF}
6 | cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx
7 |
8 |
9 | {93995380-89BD-4b04-88EB-625FBE52EBFB}
10 | h;hh;hpp;hxx;hm;inl;inc;xsd
11 |
12 |
13 | {67DA6AB6-F800-4c08-8B7A-83BB121AAD01}
14 | rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav;mfcribbon-ms
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 | 头文件
23 |
24 |
25 | 头文件
26 |
27 |
28 |
29 |
30 | 源文件
31 |
32 |
33 | 源文件
34 |
35 |
36 |
--------------------------------------------------------------------------------
/BasicTest/ReadMe.txt:
--------------------------------------------------------------------------------
1 | ========================================================================
2 | 控制台应用程序:BasicTest 项目概述
3 | ========================================================================
4 |
5 | 应用程序向导已为您创建了此 BasicTest 应用程序。
6 |
7 | 本文件概要介绍组成 BasicTest 应用程序的每个文件的内容。
8 |
9 |
10 | BasicTest.vcxproj
11 | 这是使用应用程序向导生成的 VC++ 项目的主项目文件,其中包含生成该文件的 Visual C++ 的版本信息,以及有关使用应用程序向导选择的平台、配置和项目功能的信息。
12 |
13 | BasicTest.vcxproj.filters
14 | 这是使用“应用程序向导”生成的 VC++ 项目筛选器文件。它包含有关项目文件与筛选器之间的关联信息。在 IDE 中,通过这种关联,在特定节点下以分组形式显示具有相似扩展名的文件。例如,“.cpp”文件与“源文件”筛选器关联。
15 |
16 | BasicTest.cpp
17 | 这是主应用程序源文件。
18 |
19 | /////////////////////////////////////////////////////////////////////////////
20 | 其他标准文件:
21 |
22 | StdAfx.h, StdAfx.cpp
23 | 这些文件用于生成名为 BasicTest.pch 的预编译头 (PCH) 文件和名为 StdAfx.obj 的预编译类型文件。
24 |
25 | /////////////////////////////////////////////////////////////////////////////
26 | 其他注释:
27 |
28 | 应用程序向导使用“TODO:”注释来指示应添加或自定义的源代码部分。
29 |
30 | /////////////////////////////////////////////////////////////////////////////
31 |
--------------------------------------------------------------------------------
/BasicTest/stdafx.cpp:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/landbroken/BasicKnowledge/77b2ee482b1648c14b75bfa0971a08d91286d3e3/BasicTest/stdafx.cpp
--------------------------------------------------------------------------------
/BasicTest/stdafx.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/landbroken/BasicKnowledge/77b2ee482b1648c14b75bfa0971a08d91286d3e3/BasicTest/stdafx.h
--------------------------------------------------------------------------------
/BasicTest/targetver.h:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/landbroken/BasicKnowledge/77b2ee482b1648c14b75bfa0971a08d91286d3e3/BasicTest/targetver.h
--------------------------------------------------------------------------------
/DesignPattern/1单例模式.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace DesignPattern
7 | {
8 | #region 原理版
9 |
10 | ///
11 | /// 单线程版单例模式
12 | ///
13 | public class Singleton_0
14 | {
15 | // 定义一个静态变量来保存类的实例
16 | private static Singleton_0 uniqueInstance;
17 |
18 | // 定义私有构造函数,使外界不能创建该类实例
19 | private Singleton_0()
20 | {
21 | }
22 |
23 | ///
24 | /// 定义公有方法提供一个全局访问点,同时你也可以定义公有属性来提供全局访问点
25 | ///
26 | ///
27 | public static Singleton_0 GetInstance()
28 | {
29 | // 如果类的实例不存在则创建,否则直接返回
30 | if (uniqueInstance == null)
31 | {
32 | uniqueInstance = new Singleton_0();
33 | }
34 | return uniqueInstance;
35 | }
36 | }
37 |
38 | ///
39 | /// 多线程下单例模式的实现
40 | ///
41 | public class Singleton_s
42 | {
43 | // 定义一个静态变量来保存类的实例
44 | private static Singleton_s uniqueInstance;
45 |
46 | // 定义一个标识确保线程同步
47 | private static readonly object locker = new object();
48 |
49 | // 定义私有构造函数,使外界不能创建该类实例
50 | private Singleton_s()
51 | {
52 | }
53 |
54 | ///
55 | /// 定义公有方法提供一个全局访问点,同时你也可以定义公有属性来提供全局访问点
56 | ///
57 | ///
58 | public static Singleton_s GetInstance()
59 | {
60 | // 当第一个线程运行到这里时,此时会对locker对象 "加锁",
61 | // 当第二个线程运行该方法时,首先检测到locker对象为"加锁"状态,该线程就会挂起等待第一个线程解锁
62 | // lock语句运行完之后(即线程运行完之后)会对该对象"解锁"
63 | // 双重锁定只需要一句判断就可以了
64 | if (uniqueInstance == null)
65 | {
66 | lock (locker)
67 | {
68 | // 如果类的实例不存在则创建,否则直接返回
69 | if (uniqueInstance == null)
70 | {
71 | uniqueInstance = new Singleton_s();
72 | }
73 | }
74 | }
75 | return uniqueInstance;
76 | }
77 | }
78 |
79 | #endregion
80 |
81 | #region 我的测试用实例
82 |
83 | ///
84 | /// 多线程下单例模式的实现
85 | ///
86 | public class Singleton_t
87 | {
88 | // 定义一个静态变量来保存类的实例
89 | private static Singleton_t uniqueInstance;
90 |
91 | // 定义一个标识确保线程同步
92 | private static readonly object locker = new object();
93 |
94 | // 定义私有构造函数,使外界不能创建该类实例
95 | private Singleton_t()
96 | {
97 | }
98 |
99 | ///
100 | /// 定义公有方法提供一个全局访问点,同时你也可以定义公有属性来提供全局访问点
101 | ///
102 | ///
103 | public static Singleton_t GetInstance()
104 | {
105 | // 当第一个线程运行到这里时,此时会对locker对象 "加锁",
106 | // 当第二个线程运行该方法时,首先检测到locker对象为"加锁"状态,该线程就会挂起等待第一个线程解锁
107 | // lock语句运行完之后(即线程运行完之后)会对该对象"解锁"
108 | // 双重锁定只需要一句判断就可以了
109 | if (uniqueInstance == null)
110 | {
111 | lock (locker)
112 | {
113 | // 如果类的实例不存在则创建,否则直接返回
114 | if (uniqueInstance == null)
115 | {
116 | uniqueInstance = new Singleton_t();
117 | }
118 | }
119 | }
120 | return uniqueInstance;
121 | }
122 |
123 | #region 数据
124 | public int data = 0;
125 | public string strData = "0";
126 | #endregion
127 | }
128 |
129 | #endregion
130 | }
131 |
--------------------------------------------------------------------------------
/DesignPattern/2简单工厂.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace DesignPattern.Factory
7 | {
8 | #region 参考教程的示例
9 |
10 | ///
11 | /// 菜抽象类
12 | ///
13 | public abstract class Food
14 | {
15 | public string FoodName { get; set; }
16 |
17 | // 输出点了什么菜
18 | public abstract void Print();
19 | }
20 |
21 | ///
22 | /// 西红柿炒鸡蛋这道菜
23 | ///
24 | public class TomatoScrambledEggs : Food
25 | {
26 | public override void Print()
27 | {
28 | FoodName = "一份西红柿炒蛋!";
29 | Console.WriteLine(FoodName);
30 | }
31 | }
32 |
33 | ///
34 | /// 土豆肉丝这道菜
35 | ///
36 | public class ShreddedPorkWithPotatoes : Food
37 | {
38 | public override void Print()
39 | {
40 | FoodName = "一份土豆肉丝";
41 | Console.WriteLine("一份土豆肉丝");
42 | }
43 | }
44 |
45 | ///
46 | /// 简单工厂类, 负责 炒菜
47 | ///
48 | public class FoodSimpleFactory
49 | {
50 | public static Food CreateFood(string type)
51 | {
52 | Food food = null;
53 | //equals比较两个string对象的值
54 | //==比较两个string对象是否是同一个引用,建议用equals
55 | if (type.Equals("土豆肉丝"))
56 | {
57 | food = new ShreddedPorkWithPotatoes();
58 | }
59 | else if (type.Equals("西红柿炒蛋"))
60 | {
61 | food = new TomatoScrambledEggs();
62 | }
63 |
64 | return food;
65 | }
66 | }
67 |
68 | #endregion
69 |
70 | #region 根据教程理解自己写的示例
71 |
72 | ///
73 | /// 设备抽象接口
74 | ///
75 | public interface IEquip
76 | {
77 | string GetName();
78 | }
79 |
80 | ///
81 | /// 简单工厂模式的工厂
82 | ///
83 | public class EquipSimpleFactory
84 | {
85 | private static IEquip factory = null;
86 |
87 | public static IEquip CreateFactory(string name)
88 | {
89 | switch (name)
90 | {
91 | case "gps":
92 | factory = new Gps();
93 | break;
94 | case "imu":
95 | factory = new IMU();
96 | break;
97 | default:
98 | throw new NotImplementedException();
99 | }
100 | return factory;
101 | }
102 | }
103 |
104 | ///
105 | /// GPS设备
106 | ///
107 | public class Gps : IEquip
108 | {
109 | public string GetName()
110 | {
111 | return nameof(Gps);
112 | }
113 | }
114 |
115 | ///
116 | /// 惯性测量单元设备
117 | ///
118 | public class IMU : IEquip
119 | {
120 | public string GetName()
121 | {
122 | return nameof(IMU);
123 | }
124 | }
125 |
126 | #endregion
127 | }
128 |
--------------------------------------------------------------------------------
/DesignPattern/3工厂方法.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace DesignPattern.Factory
7 | {
8 | #region 教程版
9 |
10 | public abstract class Creator
11 | {
12 | public abstract Food CreateFoddFactory();
13 | }
14 |
15 | ///
16 | /// 肉末茄子这道菜
17 | ///
18 | public class MincedMeatEggplant : Food
19 | {
20 | ///
21 | /// 重写抽象类中的方法
22 | ///
23 | public override void Print()
24 | {
25 | FoodName = "肉末茄子好了";
26 | Console.WriteLine("肉末茄子好了");
27 | }
28 | }
29 | ///
30 | /// 肉末茄子工厂类,负责创建肉末茄子这道菜
31 | ///
32 | public class MincedMeatEggplantFactory : Creator
33 | {
34 | ///
35 | /// 负责创建肉末茄子这道菜
36 | ///
37 | ///
38 | public override Food CreateFoddFactory()
39 | {
40 | return new MincedMeatEggplant();
41 | }
42 | }
43 |
44 | #endregion
45 |
46 | #region 根据教程理解自己写的示例
47 |
48 | public interface IEquipCreator
49 | {
50 | IEquip CreateFactory();
51 | }
52 |
53 | ///
54 | /// gps的工厂方法
55 | ///
56 | public class GpsFactory : IEquipCreator
57 | {
58 | public IEquip CreateFactory()
59 | {
60 | return new Gps();
61 | }
62 | }
63 |
64 | ///
65 | /// 惯性测量单元的工厂方法
66 | ///
67 | public class IMUFactory : IEquipCreator
68 | {
69 | public IEquip CreateFactory()
70 | {
71 | return new IMU();
72 | }
73 | }
74 |
75 | ///
76 | /// 摄像头工厂方法
77 | ///
78 | public class CameraFactory : IEquipCreator
79 | {
80 | public IEquip CreateFactory()
81 | {
82 | return new Camera();
83 | }
84 | }
85 |
86 | ///
87 | /// 摄像头设备
88 | ///
89 | public class Camera : IEquip
90 | {
91 | public string GetName()
92 | {
93 | return nameof(Camera);
94 | }
95 | }
96 |
97 | #endregion
98 |
99 | }
100 |
--------------------------------------------------------------------------------
/DesignPattern/4_2抽象工厂新增工厂.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace DesignPattern.Factory
7 | {
8 | #region 教程
9 |
10 | ///
11 | /// 如果绝味又想开一家湖南的分店时,因为湖南喜欢吃麻的
12 | /// 所以这是有需要有一家湖南的工厂专门制作
13 | ///
14 | public class HuNanFactory : AbstractFactory
15 | {
16 | // 制作湖南鸭脖
17 | public override YaBo CreateYaBo()
18 | {
19 | return new HuNanYaBo();
20 | }
21 |
22 | // 制作湖南鸭架
23 | public override YaJia CreateYaJia()
24 | {
25 | return new HuNanYajia();
26 | }
27 | }
28 |
29 | ///
30 | /// 湖南的鸭脖
31 | ///
32 | public class HuNanYaBo : YaBo
33 | {
34 | public override void Print()
35 | {
36 | Console.WriteLine("湖南的鸭脖");
37 | }
38 | }
39 |
40 | ///
41 | /// 湖南的鸭架
42 | ///
43 | public class HuNanYajia : YaJia
44 | {
45 | public override void Print()
46 | {
47 | Console.WriteLine("湖南的鸭架子");
48 | }
49 | }
50 |
51 | #endregion
52 |
53 | #region 自己写的
54 |
55 | #endregion
56 | }
57 |
--------------------------------------------------------------------------------
/DesignPattern/7适配器模式.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 |
6 | namespace DesignPattern.Adapter
7 | {
8 | #region 教程
9 |
10 | ///
11 | /// 客户端,客户想要把2个孔的插头 转变成三个孔的插头,这个转变交给适配器就好
12 | /// 既然适配器需要完成这个功能,所以它必须同时具体2个孔插头和三个孔插头的特征
13 | ///
14 | public class Client
15 | {
16 | public static void test()
17 | {
18 | // 现在客户端可以通过电适配要使用2个孔的插头了
19 | IThreeHole threehole = new PowerAdapter();
20 | threehole.Request();
21 | Console.ReadLine();
22 | }
23 | }
24 |
25 | ///
26 | /// 三个孔的插头,也就是适配器模式中的目标角色
27 | ///
28 | public interface IThreeHole
29 | {
30 | void Request();
31 | }
32 |
33 | ///
34 | /// 两个孔的插头,源角色——需要适配的类
35 | ///
36 | public abstract class TwoHole
37 | {
38 | public void SpecificRequest()
39 | {
40 | Console.WriteLine("我是两个孔的插头");
41 | }
42 | }
43 |
44 | ///
45 | /// 适配器类,接口要放在类的后面
46 | /// 适配器类提供了三个孔插头的行为,但其本质是调用两个孔插头的方法
47 | ///
48 | public class PowerAdapter : TwoHole, IThreeHole
49 | {
50 | ///
51 | /// 实现三个孔插头接口方法
52 | ///
53 | public void Request()
54 | {
55 | // 调用两个孔插头方法
56 | this.SpecificRequest();
57 | }
58 | }
59 |
60 |
61 | #endregion
62 |
63 | #region 自己写一遍
64 |
65 | ///
66 | /// 客户端
67 | ///
68 | public class MyClient
69 | {
70 | public static void test()
71 | {
72 | //新的usb接口行为和旧的一样,都是插进去
73 | //但是usb形状不一样(函数接口不一样)
74 | //适配器模型转换一下就能调用旧接口了
75 | ITypeC typeC = new TypeC();
76 | typeC.NewUsb();
77 | Console.ReadLine();
78 | }
79 | }
80 |
81 | ///
82 | /// 新插头,也就是适配器模式中的目标角色
83 | ///
84 | public interface ITypeC
85 | {
86 | void NewUsb();
87 | }
88 |
89 | ///
90 | /// 早期的手机usb接口,源角色——需要适配的类
91 | ///
92 | public abstract class MicroUSB
93 | {
94 | public void OldUsb()
95 | {
96 | Console.WriteLine(nameof(MicroUSB)+"插入");
97 | }
98 | }
99 |
100 | ///
101 | /// 适配器类,接口要放在类的后面
102 | /// 适配器类提供了新的插头,但其本质是调用旧插头的方法
103 | ///
104 | public class TypeC : MicroUSB, ITypeC
105 | {
106 | ///
107 | /// 实现新的插头方法
108 | ///
109 | public void NewUsb()
110 | {
111 | // 调用旧插头方法
112 | this.OldUsb();
113 | }
114 | }
115 |
116 |
117 | #endregion
118 | }
119 |
--------------------------------------------------------------------------------
/DesignPattern/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/DesignPattern/DesignPattern.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DesignPattern", "DesignPattern\DesignPattern.csproj", "{33B1CF6A-2913-4B0D-937D-C7B5BBA00DAF}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {33B1CF6A-2913-4B0D-937D-C7B5BBA00DAF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {33B1CF6A-2913-4B0D-937D-C7B5BBA00DAF}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {33B1CF6A-2913-4B0D-937D-C7B5BBA00DAF}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {33B1CF6A-2913-4B0D-937D-C7B5BBA00DAF}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | EndGlobal
23 |
--------------------------------------------------------------------------------
/DesignPattern/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Windows.Forms;
5 |
6 | namespace DesignPattern
7 | {
8 | static class Program
9 | {
10 | ///
11 | /// 应用程序的主入口点。
12 | ///
13 | [STAThread]
14 | static void Main()
15 | {
16 | Application.EnableVisualStyles();
17 | Application.SetCompatibleTextRenderingDefault(false);
18 | Application.Run(new Form1());
19 | }
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/DesignPattern/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("DesignPattern")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("DesignPattern")]
13 | [assembly: AssemblyCopyright("Copyright © 2018")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | //将 ComVisible 设置为 false 将使此程序集中的类型
18 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("33b1cf6a-2913-4b0d-937d-c7b5bba00daf")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”: :
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------
/DesignPattern/Properties/Resources.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // 此代码由工具生成。
4 | // 运行时版本: 4.0.30319.42000
5 | //
6 | // 对此文件的更改可能导致不正确的行为,如果
7 | // 重新生成代码,则所做更改将丢失。
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace DesignPattern.Properties
12 | {
13 |
14 |
15 | ///
16 | /// 强类型资源类,用于查找本地化字符串等。
17 | ///
18 | // 此类是由 StronglyTypedResourceBuilder
19 | // 类通过类似于 ResGen 或 Visual Studio 的工具自动生成的。
20 | // 若要添加或删除成员,请编辑 .ResX 文件,然后重新运行 ResGen
21 | // (以 /str 作为命令选项),或重新生成 VS 项目。
22 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")]
23 | [global::System.Diagnostics.DebuggerNonUserCodeAttribute()]
24 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
25 | internal class Resources
26 | {
27 |
28 | private static global::System.Resources.ResourceManager resourceMan;
29 |
30 | private static global::System.Globalization.CultureInfo resourceCulture;
31 |
32 | [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
33 | internal Resources()
34 | {
35 | }
36 |
37 | ///
38 | /// 返回此类使用的缓存 ResourceManager 实例。
39 | ///
40 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
41 | internal static global::System.Resources.ResourceManager ResourceManager
42 | {
43 | get
44 | {
45 | if ((resourceMan == null))
46 | {
47 | global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("DesignPattern.Properties.Resources", typeof(Resources).Assembly);
48 | resourceMan = temp;
49 | }
50 | return resourceMan;
51 | }
52 | }
53 |
54 | ///
55 | /// 覆盖当前线程的 CurrentUICulture 属性
56 | /// 使用此强类型的资源类的资源查找。
57 | ///
58 | [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)]
59 | internal static global::System.Globalization.CultureInfo Culture
60 | {
61 | get
62 | {
63 | return resourceCulture;
64 | }
65 | set
66 | {
67 | resourceCulture = value;
68 | }
69 | }
70 | }
71 | }
72 |
--------------------------------------------------------------------------------
/DesignPattern/Properties/Settings.Designer.cs:
--------------------------------------------------------------------------------
1 | //------------------------------------------------------------------------------
2 | //
3 | // This code was generated by a tool.
4 | // Runtime Version:4.0.30319.42000
5 | //
6 | // Changes to this file may cause incorrect behavior and will be lost if
7 | // the code is regenerated.
8 | //
9 | //------------------------------------------------------------------------------
10 |
11 | namespace DesignPattern.Properties
12 | {
13 |
14 |
15 | [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()]
16 | [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "11.0.0.0")]
17 | internal sealed partial class Settings : global::System.Configuration.ApplicationSettingsBase
18 | {
19 |
20 | private static Settings defaultInstance = ((Settings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new Settings())));
21 |
22 | public static Settings Default
23 | {
24 | get
25 | {
26 | return defaultInstance;
27 | }
28 | }
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/DesignPattern/Properties/Settings.settings:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/HuaWei/10字符个数统计.cpp:
--------------------------------------------------------------------------------
1 | #include "stdafx.h"
2 | #include "HuaWei.h"
3 | #include
4 | #include
5 | #include
6 | #include