- 博客(20)
- 收藏
- 关注
原创 排序-归并排序
#include<iostream>#include<ctime>#define MAX 20using namespace std;/* 归并排序 归并排序的思想在于把一个无序序列拆解成单个元素的序列,再把拆分的序列中的元素按大小放置在一个辅助数组中 然后把辅助序列中的元素拷贝至序列的原位置递归完成排序*/void _sort(int* arr, int loc_1, int loc_2, int loc_3, int loc_4); //合并数组.
2022-05-20 18:30:41
92
原创 数据结构-字符串(string)(c++)
#include<iostream>//string类的基本实现class String{public: String(int max = 10); //默认构造 String(const char* str); //常量构造 String(const String& str); //拷贝构造 String(int num, char str); //字符构造 void print(); //输出数组 ..
2022-05-09 11:44:24
257
原创 数据结构-图(十字链表)(c++实现)
#include<iostream>using namespace std;//网:带权值的图//有向网的十字链表表示法//弧结点class node{public: node(int num_1,int num_2,int num_3); ~node(); int weight; //弧的权值 int start, end; //弧的起始位置和结束位置在顶点表中的下标 node* in, * out; //下一入度和下一出度};.
2022-05-07 17:50:28
440
2
原创 字符串匹配算法(BF)(c++)
#include<iostream>//暴力匹配字符串void test(){ char arr[] = "ABBBABABBABABABBABABABABBABABABABBABABABABBABBBBAABABBAAAAABABABBAABC"; char _arr[] = "ABABABBAA"; int L1 = sizeof(arr) - 1; //获取主串的最大下标 int L2 = sizeof(_arr) - 1; //获取子串的最大下标 int .
2022-05-04 18:43:11
499
原创 数据结构-双向链表(c++)
#include<iostream>using namespace std;//双向链表//双向链表在操作时要注意首尾指针的改变template<class T>class node{public: node() { data = NULL; ago = nullptr; next = nullptr; } node(T _data) { data = _data; ago = nullptr; next = nullptr; } ~node() { a.
2022-05-04 18:40:32
454
原创 数据结构-栈(链式表示)(c++)
#include<iostream>using namespace std;//链栈实现template<typename T>class node{public: node() { data = NULL; next = nullptr; } node(T _data) { data = _data; next = nullptr; } ~node() { if (next != nullptr) { next = nullptr; } } T data.
2022-05-04 18:36:45
196
原创 数据结构-栈(顺序表示)(c++)
#include<iostream>using namespace std;//顺序栈template<typename T>class listStack{public: listStack(int _max = 10) { max = _max; L = new T[max]; length = 0; top = &L[0]; } ~listStack() { if (L != nullptr) { delete[] L; } } void pu.
2022-05-04 18:34:54
78
原创 数据结构-队列(链式)(c++)
#include<iostream>using namespace std;//双向循环链队 template<typename T>class node{public: node() { data = NULL; next = nullptr; from = nullptr; } node(T _data) { data = _data; next = nullptr; from = nullptr; } T data; node* next; .
2022-05-04 18:32:21
225
原创 数据结构-队列(顺序表示)(c++)
#include<iostream>using namespace std;//循环顺序队列template<typename T>class listQueue{public: listQueue(int _max = 10) { max = _max; Q = new T[max]; tail = 0; head = 0; length = 0; } ~listQueue() { delete[] Q; } //入 void inPut(T elem.
2022-05-04 18:30:31
461
原创 数据结构-链表(c++)
#include<iostream>using namespace std;//节点template<typename T>class Node{public: Node() { this->data = NULL; this->next = nullptr; } Node(T _data) { this->data = _data; this->next = nullptr; } ~Node() { if (this->n.
2022-05-04 18:24:18
161
原创 数据结构-顺序表(c++)
#include<iostream>#define ADD 3 using namespace std;//非内置数据类型可以使用操作符重载进行数据的比较template<typename T>class List{public: //线性表的初始化 List(int n = 10){this->length = 0;this->max = n;this->L = new T[max];} //线性表的销毁 ~List() .
2022-05-04 18:18:57
333
原创 数据结构-二叉树(c++)
#include<iostream>#include<stack>using namespace std;template<class T>class node{public: node(T _data); ~node(); T data; node* lchild, *rchild;};template<class T>node<T>::node(T _data) { data = _dat...
2022-05-04 17:56:55
337
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人