c/c++
Wryyyy.
这个作者很懒,什么都没留下…
展开
-
AVL树关于不平衡旋转问题
#include<iostream> #include<vector> using namespace std; template<class K, class V> struct AVLTreeNode { AVLTreeNode(const pair<K, V>& kv) :_pLeft(nullptr), _pRight(nullptr), _pParent(nullptr), _kv(kv), _bf(0) {}; AVLTreeNode原创 2020-07-29 16:37:09 · 262 阅读 · 0 评论 -
STL_stack
namespace wh { template<class T, class Container> class stack { public: void push(const T& x) { _con.push_back(x); } void pop() { _con.pop_back(); } int size() { return _con.size(); } T& top() { return _con.bac原创 2020-07-29 16:35:02 · 101 阅读 · 0 评论 -
栈的实现
//Stack.h #pragma once #include<stdio.h> #include<assert.h> #include<stdlib.h> typedef int STDataType; typedef struct Stack { STDataType* _a; int _top; // 栈顶 int _capacity; // 容量 }Stack; // 初始化栈 void StackInit(Stack* ps); // 入栈 v原创 2020-07-29 16:06:14 · 66 阅读 · 0 评论 -
顺序表的实现
//SeqList.h #pragma once #include<stdio.h> #include<assert.h> #include<malloc.h> typedef int ElemType; typedef struct SeqList { ElemType* data; int size; // 有效数据的个数 int capacity; // 数组的容量 }SeqList; void SeqListInit(SeqList* ps原创 2020-07-29 16:04:11 · 82 阅读 · 0 评论 -
C语言操作符总结
c语言操作符详解 c语言操作符 算术操作符 移位操作符 位操作符 赋值操作符 单目操作符 关系操作符 逻辑操作符 逗号表达式 算术操作符 + - * / % 1. /操作符 如果左右两边为整数,则输出也为整数,如果要输出浮点数,那么左右两边要有一个为浮点数 2.%操作符的两边必须要为整数 移位操作符 << 左移操作符 >> ...原创 2020-07-29 16:01:20 · 87 阅读 · 0 评论 -
队列的实现
//Queue.h #pragma once #include<stdio.h> #include<malloc.h> #include<assert.h> typedef int QDataType; typedef struct QListNode { QDataType _data; struct QListNode* _next; }QNode; // 队列的结构 typedef struct Queue { QNode* _front; QNod原创 2020-07-29 16:00:44 · 99 阅读 · 0 评论 -
堆的实现
//Heap.h #pragma once #include <stdio.h> #include<assert.h> typedef int HpDataType; typedef struct Heap { HpDataType* _a; size_t _size; size_t _capacity; }Heap; void InitHeap(Heap* hp); // 堆的构建 Heap* HeapCreate(HpDataType* a, siz原创 2020-07-29 16:00:24 · 101 阅读 · 0 评论 -
有关链表的实现(单向/双向 + 不带头/带头 + 非循环/循环)
//LinkList.h 单向不带头非循环 #pragma once #include<stdio.h> #include<malloc.h> #include<assert.h> typedef int ElementType; typedef struct LinkList { ElementType e; struct LinkList* next; }LinkList; /*初始化链表*/ void InitLinkList(LinkList** LL原创 2020-07-29 15:58:25 · 73 阅读 · 0 评论 -
优先级队列实现
namespace wh { template<class T, class Container = vector<T>, class compare = wh::less<T>> class priority_queue { public: void push(const T& x) { _con.push_back(x); AdjustUp(_con.size() - 1); } void pop() { swap(_co原创 2020-07-29 15:45:45 · 59 阅读 · 0 评论 -
二叉树实现
//BinaryTree.h #pragma once #include<stdio.h> #include<malloc.h> typedef char BTDataType; typedef struct BinaryTreeNode { BTDataType _data; struct BinaryTreeNode* _left; struct BinaryTreeNode* _right; }BTNode; #include"Queue.h" // 通过前序遍原创 2020-07-29 15:51:54 · 88 阅读 · 0 评论 -
string实现
#define _CRT_SECURE_NO_WARNINGS 0 #include<iostream> #include<cstring> using namespace std; namespace test { class string { public: typedef char* iterator; /*输入输出重载*/ friend ostream& operator<<(ostream& _cout, const test原创 2020-07-29 15:30:09 · 55 阅读 · 0 评论 -
vector实现
namespace wh{ template<class T> class vector { public: typedef T* iterator; typedef T* const_iterator; vector() : _start(0), _finish(0), _endofstorage(0) {}//缺省参数构造函数 vector(const vector<T>& v) : _start(0), _finish(0), _endofstor原创 2020-07-01 17:27:14 · 73 阅读 · 0 评论 -
C语言实现扫雷
写一个简单的程序实现扫雷游戏 首先先创建头文件定义常量,以及引入的库文件 #define _CRT_SECURE_NO_WARNINGS 1 ...原创 2020-05-31 11:47:07 · 156 阅读 · 0 评论 -
STL_List
namespace wh { template<class T> struct _list_node { _list_node<T>* _prev; _list_node<T>* _next; T _data; _list_node(const T& x = T()) :_data(x), _prev(nullptr), _next(nullptr) {} }; template<class T, class Ref, class原创 2020-07-29 16:26:52 · 76 阅读 · 0 评论