code
执念如此Arcon
https://github.com/liuxinyu123
展开
-
mystring类的实现
mystring.h文件#ifndef _CMYSTRING_H_ #define _CMYSTRING_H_#include <iostream> #include <cstring>class CMyString { public: //default ctor CMyString(const char *s = nullptr) { if (!s)原创 2017-07-03 22:32:52 · 547 阅读 · 0 评论 -
单例模式的c++实现
singleton.h文件#ifndef _SINGLETON_H_ #define _SINGLETON_H_class Singleton { public: static Singleton* get_instance() { if(!_instance) return new Singleton(); return原创 2017-07-03 23:30:10 · 259 阅读 · 0 评论 -
寻找数组的第k个最大者
使用了两种解法: 将全部元素从大到小排序,然后返回第k-1位置的元素 选取前k个元素进行排序,然后将剩余的元素插入到对应位置,没插入一次,抛弃最后一个元素,最后返回最后位置的元素 代码如下:#include <iostream> #include <vector>using namespace std;void bubble_sort(vector<int> &iv); inline void s原创 2017-07-05 22:40:59 · 230 阅读 · 0 评论 -
list类的C++模板实现
/* 2017/07/20 Liu YK */#pragma once #include <iostream> #include <ctime> #include <cassert> #include <cstdlib>namespace MYSTL {#define ListNodePosi(T) ListNode<T>* typedef int Rank; template<typ原创 2017-07-26 22:44:34 · 2080 阅读 · 1 评论 -
vector模板类的C++实现
/* 2017/07/19 Liu YK */#pragma once #include <cassert> #include <iostream> #include <cstdlib> #include <ctime>namespace MYSTL { typedef int Rank; const int DEFAULT_CAPACITY = 5; template<typ原创 2017-07-26 22:40:00 · 4478 阅读 · 0 评论